Syntactic Confectionery Delight PerlMonks

solving system of equations with complex expressions

 on Oct 24, 2011 at 21:13 UTC ( #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.
Michael

Comment on solving system of equations with complex expressions
Replies are listed 'Best First'.
Re: solving system of equations with complex expressions
by Albannach (Prior) 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 (Chancellor) on Oct 24, 2011 at 23:19 UTC

Create A New User
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? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2016-05-24 14:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
What font do you use for programming?

Results (313 votes). Check out past polls.