Hi, I am new to Sympy. I am using Sympy 0.7.6 on Ubuntu, Python 2.7.6.

62 views
Skip to first unread message

Srinivasan Rajaraman

unread,
May 27, 2015, 6:50:40 PM5/27/15
to sy...@googlegroups.com
I am trying to create a polynomial expression  through the following commands:

from sympy import *

x = symbols('x')

P1 = sympy.poly(sympy.symbols('b0:3'), x)

>>> P1
Poly(b0*x**2 + b1*x + b2, x, domain='ZZ[b0,b1,b2]')

How do I extract the expression from the polynomial object?

In the previous version Sympy 0.6.7, there used to be an attribute for the 'Poly' class, 'as_basic().'

However, this attribute does not exist for the Poly class anymore.  Could somebody help me in extracting the polynomial expression from the Poly object?


Srini


Gaurav Dhingra

unread,
May 27, 2015, 11:13:33 PM5/27/15
to sy...@googlegroups.com
I guess .as_expr() would do the job you intend to perform

>>> P1.as_expr()
b0*x**2 + b1*x + b2

Srinivasan Rajaraman

unread,
May 28, 2015, 12:10:22 PM5/28/15
to sy...@googlegroups.com
Thanks!  That worked.  I just didn't know which procedure it was to extract the expression.

Gaurav Dhingra

unread,
May 29, 2015, 12:00:07 AM5/29/15
to sy...@googlegroups.com
Happy to help :)
Reply all
Reply to author
Forward
0 new messages