Python library for working with simple equations

L

lallous

Hello

Is there is any Python library that allow such things:

Given a string expression as: x + 5 + x * (y + 2), any library that
can develop the equation for example.
Or if we say factor with "x" then it renders the expression with x *
( rest of expression ).
There could be a functionality where when x,y are given then the
expression can be evaluated.
If there are two expressions, they can be added and the symbols
preserved.

Does such a thing exist?

Thanks,
Elias
 
C

Chris Rebert

Hello

Is there is any Python library that allow such things:

Given a string expression as: x + 5 + x * (y + 2), any library that
can develop the equation for example.
Or if we say factor with "x" then it renders the expression with x *
( rest of expression ).
There could be a functionality where when x,y are given then the
expression can be evaluated.
If there are two expressions, they can be added and the symbols
preserved.

Does such a thing exist?

They're called computer algebra systems:
http://en.wikipedia.org/wiki/Computer_algebra_system

SymPy is one for Python:
http://code.google.com/p/sympy/

Don't know if it supports factoring specifically; I've never used it,
I just have Google-Fu.

Cheers,
Chris
 
D

Daniel Fetchinson

Given a string expression as: x + 5 + x * (y + 2), any library that
can develop the equation for example.
Or if we say factor with "x" then it renders the expression with x *
( rest of expression ).
There could be a functionality where when x,y are given then the
expression can be evaluated.
If there are two expressions, they can be added and the symbols
preserved.

Take a look at sage: http://www.sagemath.org/
I wouldn't say it's simple, in fact it's huge, but it'll do the job.

Cheers,
Daniel
 
D

Daniel Fetchinson

Given a string expression as: x + 5 + x * (y + 2), any library that
Take a look at sage: http://www.sagemath.org/
I wouldn't say it's simple, in fact it's huge, but it'll do the job.

Probably you can isolate the part of sage that you actually need and
can throw away 95% of it.

HTH,
Daniel
 
G

geremy condra

Hello

Is there is any Python library that allow such things:

Given a string expression as: x + 5 + x * (y + 2), any library that
can develop the equation for example.
Or if we say factor with "x" then it renders the expression with x *
( rest of expression ).
There could be a functionality where when x,y are given then the
expression can be evaluated.
If there are two expressions, they can be added and the symbols
preserved.

Does such a thing exist?

Thanks,
Elias
From sage:
.... (x + 1)*x

Geremy Condra
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top