polynomials with Big-Oh

65 views
Skip to first unread message

bioin...@gmail.com

unread,
Mar 8, 2015, 5:19:29 PM3/8/15
to sy...@googlegroups.com
Given a Polynomial with an asymptotic term:

>>> from sympy import series, poly
>>> from sympy.abc import x
>>> p=poly(series(1/(1-x),n=3))
>>> p
Poly(x**2 + x + O(x**3) + 1, x, O(x**3), domain='ZZ')

how do I remove the O(x**3) term so that I can use methods like p.all_coeffs()?

Thanks in advance,
-Kevin


bioin...@gmail.com

unread,
Mar 8, 2015, 8:53:13 PM3/8/15
to sy...@googlegroups.com

On Sunday, March 8, 2015 at 7:02:20 PM UTC-4, Mihir Wadwekar wrote:
You can try something like this, though I am not sure if it's the best way to do it.

>>> Poly( p.as_expr().removeO() , domain = 'ZZ' )


That is one of the first things I tried, but not after converting to an expression.  Is it a bug that p.removeO() doesn't work on Poly instances?

Thanks!
-Kevin
 

Aaron Meurer

unread,
Mar 9, 2015, 1:26:19 AM3/9/15
to sy...@googlegroups.com
Remove the O when calling the series before you create the Poly, like
poly(series(1/(1-x),n=3).removeO()).

Aaron Meurer

On Sun, Mar 8, 2015 at 11:19 PM, Mihir Wadwekar <m.mi...@gmail.com> wrote:
> It's not a bug. It's not been defined for polynomials. Asymptotic notations
> are associated with series which are currently treated as expressions.
> Perhaps someone else can provide a better explanation.
>
> btw, for your particular case, this would be better:
>
>>>> z = series(1/(1-x),n=3).removeO() # series returns an expression
>>>> p = Poly(z, domain = 'ZZ' )
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/d6206591-6e7d-4075-9160-e12024c09c34%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages