Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Taylor expansion in SageMath returns error

Hi, I need to find the Taylor coefficient of order 7 in the variable "x4" of the following function:

var('x1 x2 x3 x4 w1 w2 w3 w4 w5 w5 w6');

g= 1/4((w1^2w3^2x1^4x2^6x3^8 + 2(w1^2w3^2x1^4x2^6 + w1^2w3x1^3x2^5)x3^7 + (w1^2w3^2x1^4x2^6 + 2w1^2w3x1^3x2^5 + 2w1^2x1^2x2^4)x3^6)x4^6 + 2((w1^2w3^2x1^4x2^6 + (w1^2w3^2x1^4 + (2w1^2w3 + w1w3^2)x1^3)x2^5)x3^7 + 2(w1^2w3^2x1^4x2^6 + (w1^2w3^2x1^4 + (3w1^2w3 + w1w3^2)x1^3)x2^5 + (w1^2w3x1^3 + (w1^2 + w1w3)x1^2)x2^4)x3^6 + (w1^2w3^2x1^4x2^6 + (w1^2w3^2x1^4 + (4w1^2w3 + w1w3^2)x1^3)x2^5 + 2(w1^2w3x1^3 + (2w1^2 + w1w3)x1^2)x2^4 + 2(w1^2x1^2 + w1x1)x2^3)x3^5)x4^5 + ((w1^2w3^2x1^4x2^6 + 2(w1^2w3^2x1^4 + (3w1^2w3 + 2w1w3^2)x1^3)x2^5 + (w1^2w3^2x1^4 + 2(3w1^2w3 + 2w1w3^2)x1^3 + 2(3w1^2 + 6w1w3 + w3^2)x1^2)x2^4)x3^6 + 2(w1^2w3^2x1^4x2^6 + (2w1^2w3^2x1^4 + (7w1^2w3 + 4w1w3^2)x1^3)x2^5 + (w1^2w3^2x1^4 + 4(2w1^2w3 + w1w3^2)x1^3 + (9w1^2 + 16w1w3 + 2w3^2)x1^2)x2^4 + (w1^2w3x1^3 + (3w1^2 + 4w1w3)x1^2 + 2(3w1 + w3)x1)x2^3)x3^5 + (w1^2w3^2x1^4x2^6 + 2(w1^2w3^2x1^4 + 2(2w1^2w3 + w1w3^2)x1^3)x2^5 + (w1^2w3^2x1^4 + 2(5w1^2w3 + 2w1w3^2)x1^3 + 2(7w1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0,7)

Then, this return:

RuntimeError: ECL says: THROW: The catch RAT-ERR is undefined. During handling of the above exception, another exception occurred: ...... TypeError: ECL says: THROW: The catch RAT-ERR is undefined.

However, if I compute taylor(g,x4,0,3) returns its expansion without problems, but in order > 3, returns error.

Can anybody say me why don't returns its taylor expansion in order beyond 3?

Taylor expansion in SageMath returns error

Hi, I need to find the Taylor coefficient of order 7 in the variable "x4" of the following function:

var('x1 x2 x3 x4 w1 w2 w3 w4 w5 w5 w6');

w6'); g= 1/4((w1^2w3^2x1^4x2^6x3^8 + 2(w1^2w3^2x1^4x2^6 + w1^2w3x1^3x2^5)x3^7 + (w1^2w3^2x1^4x2^6 + 2w1^2w3x1^3x2^5 + 2w1^2x1^2x2^4)x3^6)x4^6 + 2((w1^2w3^2x1^4x2^6 + (w1^2w3^2x1^4 + (2w1^2w3 + w1w3^2)x1^3)x2^5)x3^7 + 2(w1^2w3^2x1^4x2^6 + (w1^2w3^2x1^4 + (3w1^2w3 + w1w3^2)x1^3)x2^5 + (w1^2w3x1^3 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 + w1w3)x1^2)x2^4)x3^6 + (w1^2w3^2x1^4x2^6 + (w1^2w3^2x1^4 + (4w1^2w3 + w1w3^2)x1^3)x2^5 + 2(w1^2w3x1^3 + (2w1^2 + w1w3)x1^2)x2^4 + 2(w1^2x1^2 + w1x1)x2^3)x3^5)x4^5 + ((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))x4^2e^(w6x1x2x3) + 3((x2^3 + 2x2^2 + x2)x3^4e^(w5x1x2) + 3(x2^3 + 2x2^2 + x2)x3^3e^(w5x1x2) + 3(x2^3 + 2x2^2 + x2)x3^2e^(w5x1x2) + (x2^3 + 2x2^2 + x2)x3e^(w5x1x2))x4e^(w6x1x2x3) + ((x2^3 + 3x2^2 + 3x2 + 1)x3^3e^(w5x1x2) + 3(x2^3 + 3x2^2 + 3x2 + 1)x3^2e^(w5x1x2) + 3(x2^3 + 3x2^2 + 3x2 + 1)x3e^(w5x1x2) + (x2^3 + 3x2^2 + 3x2 + 1)e^(w5x1x2))e^(w6x1x2*x3))

3*x2^2 + 3*x2 + 1)*e^(w5*x1*x2))*e^(w6*x1*x2*x3))

For this we used the command:

taylor(g,x4,0,7)

taylor(g,x4,0,7)

Then, this return:

RuntimeError: ECL says: THROW: The catch RAT-ERR is undefined.
During handling of the above exception, another exception occurred:
......
TypeError: ECL says: THROW: The catch RAT-ERR is undefined.

undefined.

However, if I compute taylor(g,x4,0,3) returns its expansion without problems, but in order > 3, returns error.

Can anybody say me why don't returns its taylor expansion in order beyond 3?