Hi, On Fri, Jun 26, 2009 at 05:57:57PM +0200, Christophe wrote: > Thanks for that but I have a big problem. How to use all of that for f > and g which are strings ? > ======================== > > f = 'x**2 + 2*y*x + sin(z)' > g = 'x**2 + 2*y*x + sin(x)' > > ======================== > I need to work with strings because that will be a program which will > call sympy. > > Christophe. >
if you have string input then sympify() it, e.g.:
In [1]: var('x y z')
Out[1]: (x, y, z)
In [2]: f = 'x**2 + 2*y*x + sin(z)'
In [3]: F = x**2 + 2*y*x + sin(z)
In [4]: g = sympify(f)
In [5]: g
Out[5]:
2
2⋅x⋅y + sin(z) + x
In [6]: g == F
Out[6]: True
So, going back to previous examples, you get:
In [7]: sympify(f).is_polynomial(x)
Out[7]: True
Most functions in sympy can be given string input and do sympification
automatically, but in method call case you need to do it on your own.
--
Mateusz
signature.asc
Description: This is a digitally signed message part
