Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

solving system of equations with complex expressions

by Anonymous Monk
on Oct 24, 2011 at 21:13 UTC ( [id://933478]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks I'm trying to solve this problem. I want to solve a set of equations. It was an easy task if I got the equations in the next format:
2x1+3x2-7x3+7x5 = 7;
at this case I can turn them into a vector like this:

[-7,2,3,-7,0,7]
and to read set of those using Math::Matrix.

The problem starts when I'm dealing with complex expression for example:
3*x+(3*a)*sin(y+w)+12z = 5
at this case it is very hard to build a suitable vector and therefore hard to use Math::Matrix.

does any of you monks have a clue or ever encountered such a problem.
Thanks in advance.
Michael

Replies are listed 'Best First'.
Re: solving system of equations with complex expressions
by Albannach (Monsignor) on Oct 24, 2011 at 21:49 UTC
    I believe what your asking is far more difficult than coding simple one variable polynomials, as essentially you seem to be placing no limitations on the operators or even the number of variables. You're talking about building a symbolic math manipulation tool. Perhaps this will help: Math::Symbolic?

    --
    I'd like to be able to assign to an luser

Re: solving system of equations with complex expressions
by bluescreen (Friar) on Oct 24, 2011 at 21:31 UTC

    Hi, how do you pass from 2x1+3x2-7x3+7x5 = 7 to [-7,2,3,-7,0,7] also the first equation seems to be wrong given you have 22 = 7. Then you show an equation with variables. I'm not clear what are you looking for: a symbolic evaluator? an equation parser? both?

    Maybe if you explain your problem domain a little bit more people will be able to help you better

      It seems he meant the numbers after the x to be exponents. Move 7 over to the left side, you have

      -7*x0 + 2*x1 + 3*x2 - 7*x3 + 0*x4 +7*x5 = 0

        this is what I meant

Re: solving system of equations with complex expressions
by bluescreen (Friar) on Oct 25, 2011 at 00:56 UTC

    Speaking of Wolfram|Alpha, that could be a solution to your problem. instead of creating a symbolic evaluation engine, maybe you can consume it's API

Re: solving system of equations with complex expressions
by planetscape (Chancellor) on Oct 25, 2011 at 02:10 UTC

    Perhaps you want Sage?

    HTH,

    planetscape
Re: solving system of equations with complex expressions
by anneli (Pilgrim) on Oct 24, 2011 at 22:46 UTC

    I don't think so. For instance, the equation you gave has a somewhat intractable solution; Wolfram|Alpha doesn't have much on it.

Re: solving system of equations with complex expressions
by LanX (Saint) on Oct 24, 2011 at 23:19 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://933478]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-16 05:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found