Hi,

On Fri, Jun 26, 2009 at 05:30:23PM +0200, Christophe wrote:
> 
> Hello,
> I would like to know if there is a sympy way to test is an expression is 
> a polynom of the variable x ?
> 
> Best regards.
> Christophe.
> 

the simplest way to achieve this is to use Basic.is_polynomial method:

In [1]: var('x y z')
Out[1]: (x, y, z)

In [2]: f = x**2 + 2*y*x + sin(z)

In [3]: g = x**2 + 2*y*x + sin(x)

In [4]: f.is_polynomial(x)
Out[4]: True

In [5]: g.is_polynomial(x)
Out[5]: False

However, this can be done in other ways too, e.g.:

In [6]: print f.as_poly(x)
Poly(x**2 + 2*y*x + sin(z), x)

In [7]: print g.as_poly(x)
None

-- 
Mateusz

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to