Multivariate polynomial manipulation

346 views
Skip to first unread message

songuke

unread,
Jan 11, 2012, 3:54:17 AM1/11/12
to sympy
Hi all,

I'm almost new to sympy and are very excited about the polynomial
module in sympy. Basically I want to retrieve the coefficient matrix
and the monomial vector of a system of polynomials. I tried
Poly.all_coeffs and Poly.monoms but the functions threw the exception:
PolynomialError: multivariate polynomials not supported

May I know how good the support of multivariate polynomial is in
sympy? If I want to extend the polynomial module to implement these
features, could anybody show me where to start? What is the difficulty
in implementing these functions for multivariate polynomials?

Regards,
Son.

Aaron Meurer

unread,
Jan 19, 2012, 3:53:08 PM1/19/12
to sy...@googlegroups.com
We have fairly full support of multivariate polynomials. all_coeffs
apparently doesn't work for univariate polynomials. I think what you
want instead is just coeffs:

In [33]: Poly(3*x*y + 2*x**2 + 3*y*x**2).coeffs()
Out[33]: [3, 2, 3]

This uses lex order by default, but you can use any ordering.

monoms works for me:

In [29]: Poly(3*x*y + 2*x**2 + 3*y*x**2).monoms()
Out[29]: [(2, 1), (2, 0), (1, 1)]

You can easily combine these to get the coefficients by term. We
don't have specific functions to get a coefficient matrix, but it
should be pretty straight forward to get using these functions.

Aaron Meurer

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

Reply all
Reply to author
Forward
0 new messages