On Wed, Jan 25, 2023 at 4:29 PM Oscar Benjamin <oscar.j.benja...@gmail.com> wrote:
> On Wed, 25 Jan 2023 at 21:15, emanuel.c...@gmail.com > <emanuel.charpent...@gmail.com> wrote: > > > > There seems to be some funamental differences between Sympy's > integration algorithm an other ones (say Sage, Maxima, Giac, Fricas or > Mathematica). Sympy : > > > > ``` > > >>> from sympy import * > > >>> x=symbols("x", positive=True) > > >>> f=Lambda((x), (x**6+2)/(8*x**2)) > > >>> integrate(sqrt(f(x).diff(x)**2+1)*f(x)) > > (Integral(2*Abs(x**4 - x**2 + 1)/x**5, x) + Integral(2*Abs(x**4 - x**2 + > 1)/x**3, x) + Integral(x*Abs(x**4 - x**2 + 1), x) + Integral(x**3*Abs(x**4 > - x**2 + 1), x))/16 > > ``` > > > > Sage (either via Maxima's or Giac's integrators) : > > > > ``` > > sage: x=var("x", domain="positive") > > sage: f(x)=(x^6+2)/(8*x^2) > > sage: integrate((f(x).diff(x)^2+1).sqrt()*f(x),x) > > 1/128*x^8 + 1/32*x^2 + 1/32*(2*x^6 - 1)/x^4 > > Maybe it's because SymPy's integrate does not automatically factorise > under the radical (I haven't checked the code to see if factorisation > is attempted): > SymPy's integration algorithms that are currently implemented aren't particularly good with algebraic functions. They do work sometimes, but most of the time they don't. They are also quite sensitive to the exact form an expression is written in, and a typical algebraic function can be rewritten in multiple equivalent ways. Aaron Meurer > > In [29]: integrand = sqrt(f(x).diff(x)**2+1)*f(x) > > In [30]: print(integrand) > (x**6 + 2)*sqrt((3*x**3/4 - (x**6 + 2)/(4*x**3))**2 + 1)/(8*x**2) > > In [31]: print(integrand.factor()) > (x**2 + 1)*(x**6 + 2)*Abs(x**4 - x**2 + 1)/(16*x**5) > > In [32]: print(integrand.factor().integrate(x)) > x**8/128 + 3*x**2/32 - 1/(32*x**4) > > -- > 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/CAHVvXxT5Yj1Wt%2BetUE-ep%3DrZqX%2BvZ5S-VQNyGas7ubL9kvY_uA%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/CAKgW%3D6K3Rr_PvWJe_4GJtO0dfxNknJ6dibjz_%2BfjQ3YVWDXE-A%40mail.gmail.com.