> I don't have a function Poly . I presume I should use Polynomial

Poly, and 'polys' module was added after 0.5.13 release, so if
you wish to use this you would need latest HG repository.

Of course you can use Polynomial, however the interface
is a bit different. Note also that 'polynomials' module is
no longer maintained.

In [19]: f=2*x**3+3*x*y+1

In [20]: p = Polynomial(f, var=x)

In [21]: p.degree()
Out[21]: 3

In [22]: q = Polynomial(f, var=(x,y))

In [23]: q.degree()
Out[23]: 3

Mateusz

2008/3/29, Colin Gillespie <[EMAIL PROTECTED]>:
>
>  Thanks for the quick response.
>
>  When I do
>  from sympy import *
>  I don't have a function Poly . I presume I should use Polynomial
>  instead?
>
>  Cheers
>
>  Colin
>
>
>  On Mar 29, 3:54 pm, "Mateusz Paprocki" <[EMAIL PROTECTED]> wrote:
>  > Hi,
>  >
>  > given the following input
>  >
>  > In [1]: f=2*x**3+3*x*y+1
>  >
>  > we get an expression:
>  >
>  > In [2]: type(f)
>  > Out[2]: <class 'sympy.core.add.Add'>
>  >
>  > You can convert this to a polynomial:
>  >
>  > In [3]: p = Poly(f, x)
>  >
>  > In [4]: p
>  > Out[4]: Poly((2, 3*y, 1), ((3,), (1,), (0,)), (x,), 'grlex')
>  >
>  > and then:
>  >
>  > In [5]: p.degree
>  > Out[5]: 3
>  >
>  > In [6]: p.coeff(0)
>  > Out[6]: 1
>  >
>  > In [7]: p.coeff(1)
>  > Out[7]: 3*y
>  >
>  > In [8]: p.coeff(2)
>  > Out[8]: 0
>  >
>  > In [9]: p.coeff(3)
>  > Out[9]: 2
>  >
>  > The same way you can work with MV polynomials:
>  >
>  > In [10]: q = Poly(f, x, y)
>  >
>  > In [11]: q
>  > Out[11]: Poly((2, 3, 1), ((3, 0), (1, 1), (0, 0)), (x, y), 'grlex')
>  >
>  > In [12]: q.degree
>  > Out[12]: 3
>  >
>  > In [13]: q.coeff(3, 0)
>  > Out[13]: 2
>  >
>  > In [14]: q.coeff(2, 1)
>  > Out[14]: 0
>  >
>  > For more information refer to 'polys' module docstrings, eg. Poly? in 
> ipython.
>  >
>  > Mateusz
>  >
>
> > 2008/3/29, Colin Gillespie <[EMAIL PROTECTED]>:
>
> >
>  >
>  >
>  > >  Dear All,
>  >
>  > >  Are there any inbuilt function to work with degrees of polynomials?
>  > >  For example,
>  >
>  > >  x=Symbol('x')
>  > >  y=symbol('y')
>  >
>  > >  f=2*x**3+3*x*y+1
>  >
>  > >  So
>  >
>  > >  f.highestDegree(x) would return 3
>  > >  f.coeff(x**1) would return 3*y
>  >
>  > >  Many thanks
>  >
>  > >  Colin
>  >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to