Thanks for clarifying. On Sun, 26 Feb 2023, 18:48 Oscar Benjamin, <oscar.j.benja...@gmail.com> wrote:
> On Sun, 26 Feb 2023 at 11:33, Suchit K <suchitkarunaka...@gmail.com> > wrote: > > > > Why does Poly.integrate() function doesn't give correct answer for > asymptotic expressions like O(x**2)? > > Example: > > from sympy import * > > x = Symbol('x') > > exp = Poly(O(x**4)) > > print(exp.integrate()) #prints 1/2*O(x**4)**2 instead of O(x**5) > > A Poly object considers itself to be a polynomial function of some > generator so Poly(O(x**4)) is a polynomial function of O(x**4). Notice > that when you call integrate here you don't specify what variable you > want to integrate with respect to but if you had specified > exp.integrate(x) you would have seen an error because the Poly > considers itself to be a function of O(x**4) rather than x. > > There is no way that Poly can do anything sensible with something > O(x**4) so just don't use Poly for this: > > >>> O(x**4).integrate(x) > O(x**5) > > Calculus with big-O objects is still questionable but SymPy currently > has the behaviour you expect for integration and differentiation. > > -- > Oscar > > -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/CAHVvXxS-%2B2dpjfqwi_G2Eg1gVjJJNKoy%2BNX9YKkggV5NUz%3DgTg%40mail.gmail.com > . > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAO9wTFj2S000_5%3Dp4OHNJ6T0%3D4i%3DtB0Amn9NAaXocd9hpRx-Og%40mail.gmail.com.