FAQ
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

Search Discussions

  • Chris Rebert at Feb 18, 2010 at 9:17 am

    On Thu, Feb 18, 2010 at 1:09 AM, lallous wrote:
    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
  • Daniel Fetchinson at Feb 18, 2010 at 9:24 am

    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

    --
    Psss, psss, put it down! - http://www.cafepress.com/putitdown
  • Daniel Fetchinson at Feb 18, 2010 at 10:50 am

    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.
    Probably you can isolate the part of sage that you actually need and
    can throw away 95% of it.

    HTH,
    Daniel



    --
    Psss, psss, put it down! - http://www.cafepress.com/putitdown
  • Geremy condra at Feb 18, 2010 at 3:30 pm

    On Thu, Feb 18, 2010 at 4:09 AM, lallous wrote:
    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
    --
    http://mail.python.org/mailman/listinfo/python-list
    From sage:
    x = var('x')
    g = x**2 + x
    g(x=5)
    30
    g.factor
    ... (x + 1)*x

    Geremy Condra

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedFeb 18, '10 at 9:09a
activeFeb 18, '10 at 3:30p
posts5
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase