Problem with `series`

45 views
Skip to first unread message

emanuel.c...@gmail.com

unread,
Aug 22, 2024, 8:26:19 AM8/22/24
to sympy

The series method of a (large) expressin doesn’t return :

from sympy import * x1, x2, x3, x4, w1, w2, w3, w4, w5, w5, w6 = symbols("x1, x2, x3, x4, w1, w2, w3, w4, w5, w5, w6") g= 1/4*((w1**2*w3**2*x1**4*x2**6*x3**8 + 2*(w1**2*w3**2*x1**4*x2**6 + w1**2*w3*x1**3*x2**5)*x3**7 + (w1**2*w3**2*x1**4*x2**6 + 2*w1**2*w3*x1**3*x2**5 + 2*w1**2*x1**2*x2**4)*x3**6)*x4**6 + 2*((w1**2*w3**2*x1**4*x2**6 + (w1**2*w3**2*x1**4 + (2*w1**2*w3 + w1*w3**2)*x1**3)*x2**5)*x3**7 + 2*(w1**2*w3**2*x1**4*x2**6 + (w1**2*w3**2*x1**4 + (3*w1**2*w3 + w1*w3**2)*x1**3)*x2**5 + (w1**2*w3*x1**3 + (w1**2 + w1*w3)*x1**2)*x2**4)*x3**6 + (w1**2*w3**2*x1**4*x2**6 + (w1**2*w3**2*x1**4 + (4*w1**2*w3 + w1*w3**2)*x1**3)*x2**5 + 2*(w1**2*w3*x1**3 + (2*w1**2 + w1*w3)*x1**2)*x2**4 + 2*(w1**2*x1**2 + w1*x1)*x2**3)*x3**5)*x4**5 + ((w1**2*w3**2*x1**4*x2**6 + 2*(w1**2*w3**2*x1**4 + (3*w1**2*w3 + 2*w1*w3**2)*x1**3)*x2**5 + (w1**2*w3**2*x1**4 + 2*(3*w1**2*w3 + 2*w1*w3**2)*x1**3 + 2*(3*w1**2 + 6*w1*w3 + w3**2)*x1**2)*x2**4)*x3**6 + 2*(w1**2*w3**2*x1**4*x2**6 + (2*w1**2*w3**2*x1**4 + (7*w1**2*w3 + 4*w1*w3**2)*x1**3)*x2**5 + (w1**2*w3**2*x1**4 + 4*(2*w1**2*w3 + w1*w3**2)*x1**3 + (9*w1**2 + 16*w1*w3 + 2*w3**2)*x1**2)*x2**4 + (w1**2*w3*x1**3 + (3*w1**2 + 4*w1*w3)*x1**2 + 2*(3*w1 + w3)*x1)*x2**3)*x3**5 + (w1**2*w3**2*x1**4*x2**6 + 2*(w1**2*w3**2*x1**4 + 2*(2*w1**2*w3 + w1*w3**2)*x1**3)*x2**5 + (w1**2*w3**2*x1**4 + 2*(5*w1**2*w3 + 2*w1*w3**2)*x1**3 + 2*(7*w1**2 + 10*w1*w3 + w3**2)*x1**2)*x2**4 + 2*(w1**2*w3*x1**3 + (5*w1**2 + 4*w1*w3)*x1**2 + 2*(5*w1 + w3)*x1)*x2**3 + 2*(w1**2*x1**2 + 4*w1*x1 + 2)*x2**2)*x3**4)*x4**4 + 2*(((w1**2*w3 + w1*w3**2)*x1**3*x2**5 + (2*(w1**2*w3 + w1*w3**2)*x1**3 + (3*w1**2 + 10*w1*w3 + 2*w3**2)*x1**2)*x2**4 + ((w1**2*w3 + w1*w3**2)*x1**3 + (3*w1**2 + 10*w1*w3 + 2*w3**2)*x1**2 + 4*(3*w1 + 2*w3)*x1)*x2**3)*x3**5 + (2*(w1**2*w3 + w1*w3**2)*x1**3*x2**5 + (4*(w1**2*w3 + w1*w3**2)*x1**3 + (7*w1**2 + 22*w1*w3 + 4*w3**2)*x1**2)*x2**4 + 2*((w1**2*w3 + w1*w3**2)*x1**3 + 2*(2*w1**2 + 6*w1*w3 + w3**2)*x1**2 + (17*w1 + 10*w3)*x1)*x2**3 + ((w1**2 + 2*w1*w3)*x1**2 + 2*(5*w1 + 2*w3)*x1 + 8)*x2**2)*x3**4 + ((w1**2*w3 + w1*w3**2)*x1**3*x2**5 + 2*((w1**2*w3 + w1*w3**2)*x1**3 + (2*w1**2 + 6*w1*w3 + w3**2)*x1**2)*x2**4 + ((w1**2*w3 + w1*w3**2)*x1**3 + (5*w1**2 + 14*w1*w3 + 2*w3**2)*x1**2 + 12*(2*w1 + w3)*x1)*x2**3 + ((w1**2 + 2*w1*w3)*x1**2 + 2*(7*w1 + 2*w3)*x1 + 12)*x2**2 + 2*(w1*x1 + 2)*x2)*x3**3)*x4**3 + 24*(x2**2 + 2*x2 + 1)*x3**2 + 2*(((w1**2 + 4*w1*w3 + w3**2)*x1**2*x2**4 + 2*((w1**2 + 4*w1*w3 + w3**2)*x1**2 + (8*w1 + 7*w3)*x1)*x2**3 + ((w1**2 + 4*w1*w3 + w3**2)*x1**2 + 2*(8*w1 + 7*w3)*x1 + 20)*x2**2)*x3**4 + 2*((w1**2 + 4*w1*w3 + w3**2)*x1**2*x2**4 + (2*(w1**2 + 4*w1*w3 + w3**2)*x1**2 + 3*(6*w1 + 5*w3)*x1)*x2**3 + ((w1**2 + 4*w1*w3 + w3**2)*x1**2 + 4*(5*w1 + 4*w3)*x1 + 27)*x2**2 + ((2*w1 + w3)*x1 + 7)*x2)*x3**3 + ((w1**2 + 4*w1*w3 + w3**2)*x1**2*x2**4 + 2*((w1**2 + 4*w1*w3 + w3**2)*x1**2 + 2*(5*w1 + 4*w3)*x1)*x2**3 + ((w1**2 + 4*w1*w3 + w3**2)*x1**2 + 6*(4*w1 + 3*w3)*x1 + 36)*x2**2 + 2*((2*w1 + w3)*x1 + 9)*x2 + 2)*x3**2)*x4**2 + 24*x2**2 + 48*(x2**2 + 2*x2 + 1)*x3 + 12*(((w1 + w3)*x1*x2**3 + (2*(w1 + w3)*x1 + 5)*x2**2 + ((w1 + w3)*x1 + 5)*x2)*x3**3 + (2*(w1 + w3)*x1*x2**3 + (4*(w1 + w3)*x1 + 11)*x2**2 + 2*((w1 + w3)*x1 + 6)*x2 + 1)*x3**2 + ((w1 + w3)*x1*x2**3 + 2*((w1 + w3)*x1 + 3)*x2**2 + ((w1 + w3)*x1 + 7)*x2 + 1)*x3)*x4 + 48*x2 + 24)*exp(-w2*x1*x2*x3*x4)/((x2**3*x3**6*exp(w5*x1*x2) + 3*x2**3*x3**5*exp(w5*x1*x2) + 3*x2**3*x3**4*exp(w5*x1*x2) + x2**3*x3**3*exp(w5*x1*x2))*x4**3*exp(w6*x1*x2*x3) + 3*((x2**3 + x2**2)*x3**5*exp(w5*x1*x2) + 3*(x2**3 + x2**2)*x3**4*exp(w5*x1*x2) + 3*(x2**3 + x2**2)*x3**3*exp(w5*x1*x2) + (x2**3 + x2**2)*x3**2*exp(w5*x1*x2))*x4**2*exp(w6*x1*x2*x3) + 3*((x2**3 + 2*x2**2 + x2)*x3**4*exp(w5*x1*x2) + 3*(x2**3 + 2*x2**2 + x2)*x3**3*exp(w5*x1*x2) + 3*(x2**3 + 2*x2**2 + x2)*x3**2*exp(w5*x1*x2) + (x2**3 + 2*x2**2 + x2)*x3*exp(w5*x1*x2))*x4*exp(w6*x1*x2*x3) + ((x2**3 + 3*x2**2 + 3*x2 + 1)*x3**3*exp(w5*x1*x2) + 3*(x2**3 + 3*x2**2 + 3*x2 + 1)*x3**2*exp(w5*x1*x2) + 3*(x2**3 + 3*x2**2 + 3*x2 + 1)*x3*exp(w5*x1*x2) + (x2**3 + 3*x2**2 + 3*x2 + 1)*exp(w5*x1*x2))*exp(w6*x1*x2*x3)) from time import time as stime t0=stime() foo=g.series(x4, 0, 7) t1=stime() print(t1-t0)

“never” returns (i. e. doesn’t return after 40 minutes).

FWIW, this series can be computed without problems and in short times with Giac, Mathematica and Sage (using Sage’s series in the latter case). Maxima standalone can compute it via taylor, but fails when called from Sage.

Relevant posts/threads in sage-support and ask.sagemath.org.

Oscar Benjamin

unread,
Aug 22, 2024, 8:43:35 AM8/22/24
to sy...@googlegroups.com
The general approach for computing series in SymPy is algorithmically
misdesigned.

See:
https://github.com/sympy/sympy/issues/26957
> --
> 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 view this discussion on the web visit https://groups.google.com/d/msgid/sympy/06760f72-6c19-4dd3-8b1c-edcf70a9bbdcn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages