Question: why odetest sometimes works and sometimes gives internal error, all by random?

Is there something one can do to make Maple give same result each time? It seems all random.

Calling odetest sometimes gives internal error. 

            Error, (in trig/normal/sincosargs) too many levels of recursion

But it is random when and how it happens. Worksheet below shows that sometimes when adding infolevel[odetest]:=5; make the error go away. sometimes trying 2 or 3 times also makes the error go away.

This makes it impossible to reason about things, as sometimes I get different result using same exact code.

Is there something one can do to remove this internal error? Why it happens sometimes only?  Do I need to clear something before calling odetest to make sure same result is obtained each time?

interface(version);

`Standard Worksheet Interface, Maple 2024.2, Windows 10, October 29 2024 Build ID 1872373`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1841 and is the same as the version installed in this computer, created 2025, January 3, 8:59 hours Pacific Time.`

libname;

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

restart;

sol:=y(x) = 1/2*x*(-1-(1+I*3^(1/2))*((I*2^(1/2)-1+I)*(I*2^(1/2)+1+I)^2)^(2/3)-2*((I*
2^(1/2)-1+I)*(I*2^(1/2)+1+I)^2)^(1/3)-I*((I*2^(1/2)+I)^2-1)*3^(1/2)+(I*2^(1/2)+
I)^2)/((I*2^(1/2)-1+I)*(I*2^(1/2)+1+I)^2)^(1/3)/(I*2^(1/2)+I);
ode:=x^3+3*x*y(x)^2+(y(x)^3+3*x^2*y(x))*diff(y(x),x) = 0

y(x) = (1/2)*x*(-1-(1+I*3^(1/2))*((I*2^(1/2)+(-1+I))*(I*2^(1/2)+1+I)^2)^(2/3)-2*((I*2^(1/2)+(-1+I))*(I*2^(1/2)+1+I)^2)^(1/3)-I*((I*2^(1/2)+I)^2-1)*3^(1/2)+(I*2^(1/2)+I)^2)/(((I*2^(1/2)+(-1+I))*(I*2^(1/2)+1+I)^2)^(1/3)*(I*2^(1/2)+I))

x^3+3*x*y(x)^2+(y(x)^3+3*x^2*y(x))*(diff(y(x), x)) = 0

odetest(sol,ode,y(x));

Error, (in trig/normal/sincosargs) too many levels of recursion

odetest(sol,ode);

Error, (in trig/normal/sincosargs) too many levels of recursion

infolevel[odetest]:=5;

5

odetest(sol,ode);

odetest: Performing an implicit solution test

odetest: Performing an explicit (try hard) solution test

odetest: Performing an implicit solution (II) test

odetest: Performing another explicit (try soft) solution test

0

odetest(sol,ode,y(x));

odetest: Performing an implicit solution test

odetest: Performing an explicit (try hard) solution test

odetest: Performing an implicit solution (II) test

odetest: Performing another explicit (try soft) solution test

0

infolevel[odetest]:=0;

0

odetest(sol,ode,y(x));

0

restart;

sol:=y(x) = 1/2*x*(-1-(1+I*3^(1/2))*((I*2^(1/2)-1+I)*(I*2^(1/2)+1+I)^2)^(2/3)-2*((I*
2^(1/2)-1+I)*(I*2^(1/2)+1+I)^2)^(1/3)-I*((I*2^(1/2)+I)^2-1)*3^(1/2)+(I*2^(1/2)+
I)^2)/((I*2^(1/2)-1+I)*(I*2^(1/2)+1+I)^2)^(1/3)/(I*2^(1/2)+I);
ode:=x^3+3*x*y(x)^2+(y(x)^3+3*x^2*y(x))*diff(y(x),x) = 0

y(x) = (1/2)*x*(-1-(1+I*3^(1/2))*((I*2^(1/2)+(-1+I))*(I*2^(1/2)+1+I)^2)^(2/3)-2*((I*2^(1/2)+(-1+I))*(I*2^(1/2)+1+I)^2)^(1/3)-I*((I*2^(1/2)+I)^2-1)*3^(1/2)+(I*2^(1/2)+I)^2)/(((I*2^(1/2)+(-1+I))*(I*2^(1/2)+1+I)^2)^(1/3)*(I*2^(1/2)+I))

x^3+3*x*y(x)^2+(y(x)^3+3*x^2*y(x))*(diff(y(x), x)) = 0

odetest(sol,ode,y(x));

Error, (in trig/normal/sincosargs) too many levels of recursion

odetest(sol,ode,y(x));

Error, (in trig/normal/sincosargs) too many levels of recursion

odetest(sol,ode,y(x));

0

 

 

Download why_odetest_sometimes_fail_internal.mw

Add tracelast; after an error gives long output with this at end

...
#(\`trig/normal\`,8): sincosargs := [\`trig/normal/sincosargs\`(a)];
 \`trig/normal/sincosargs\` called with arguments: ((-2472*2^(1/2)+3496)*3^(1/2)-4288*2^(1/2)+6064)*(10+7*2^(1/2))^(1/2)+(6008*6^(1/2)-8496*3^(1/2)+10408*2^(1/2)-14720)*cos((1/24)*Pi)
 #(\`trig/normal/sincosargs\`,2): return op(map(procname,{op(x)}))
 \`trig/normal/sincosargs\` called with arguments: ((-2472*2^(1/2)+3496)*3^(1/2)-4288*2^(1/2)+6064)*(10+7*2^(1/2))^(1/2)
 #(\`trig/normal/sincosargs\`,2): return op(map(procname,{op(x)}))
 \`trig/normal/sincosargs\` called with arguments: (-2472*2^(1/2)+3496)*3^(1/2)-4288*2^(1/2)+6064
 #(\`trig/normal/sincosargs\`,2): return op(map(procname,{op(x)}))
 \`trig/normal/sincosargs\` called with arguments: (-2472*2^(1/2)+3496)*3^(1/2)
 #(\`trig/normal/sincosargs\`,2): return op(map(procname,{op(x)}))
 \`trig/normal/sincosargs\` called with arguments: -2472*2^(1/2)+3496
 #(\`trig/normal/sincosargs\`,2): return op(map(procname,{op(x)}))
 \`trig/normal/sincosargs\` called with arguments: -2472*2^(1/2)
 #(\`trig/normal/sincosargs\`,2): return op(map(procname,{op(x)}))

Not only is it random error, it also can not be cought using try/catch. So the whole program now stop and there is no way around it. If it was at least possible to trap the error, then it will not be a big deal. But when not even possible to trap Maple errors, then what is one to do? 

 

Update Jan 18, 2025

I did not want to make new post on this, even though the error is different, but it is similar issue to this post.

I found another example of this random failure of odetest using same input.  May be this will help Maplesoft find the cause. 

The internal error this time is Error, (in depends) too many levels of recursion

In this worksheet below. the same ode and 3 solutions were used. As you see, sometimes odetest do not generate internal error, and sometimes it does. All happen on 3rd call to odetest. 

So it is completely random why this happen. The first and 4ht tries generate no error, but the second and the third do. All were run after restart is called. So one would expect same output from each try,

restart;

interface(version);
Physics:-Version();

`Standard Worksheet Interface, Maple 2024.2, Windows 10, October 29 2024 Build ID 1872373`

`The "Physics Updates" version in the MapleCloud is 1841 and is the same as the version installed in this computer, created 2025, January 3, 8:59 hours Pacific Time.`

First Try

 

ode:=1+y(x)^2+(x-exp(-arctan(y(x))))*diff(y(x),x) = 0;
sol_1:=y(x) = -tan(LambertW(-x/exp(_C1))+_C1);
timelimit(30,odetest(sol_1,ode,y(x)));

sol_2:=x*exp(arctan(y(x)))-arctan(y(x)) = _C1;
timelimit(30,odetest(sol_2,ode,y(x)));

sol_3:=y(x) = tan(-LambertW(-x*exp(_C2))+_C2);
timelimit(30,odetest(sol_3,ode,y(x)));

1+y(x)^2+(x-exp(-arctan(y(x))))*(diff(y(x), x)) = 0

y(x) = -tan(LambertW(-x/exp(_C1))+_C1)

4*LambertW(-x*exp(-c__1))*exp(-I*arctanh(exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)/(exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1)-1/(exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1))+(2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)/((exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1)^2*x*(1+LambertW(-x*exp(-c__1))))+4*exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)/((exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1)^2*(1+LambertW(-x*exp(-c__1))))

x*exp(arctan(y(x)))-arctan(y(x)) = c__1

0

y(x) = tan(-LambertW(-x*exp(_C2))+_C2)

Error, (in depends) too many levels of recursion

 

 

Second Try

 

restart;

ode:=1+y(x)^2+(x-exp(-arctan(y(x))))*diff(y(x),x) = 0;
sol_1:=y(x) = -tan(LambertW(-x/exp(_C1))+_C1);
timelimit(30,odetest(sol_1,ode,y(x)));

sol_2:=x*exp(arctan(y(x)))-arctan(y(x)) = _C1;
timelimit(30,odetest(sol_2,ode,y(x)));

sol_3:=y(x) = tan(-LambertW(-x*exp(_C2))+_C2);
timelimit(30,odetest(sol_3,ode,y(x)));

1+y(x)^2+(x-exp(-arctan(y(x))))*(diff(y(x), x)) = 0

y(x) = -tan(LambertW(-x/exp(_C1))+_C1)

4*exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)/((exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1)^2*(1+LambertW(-x*exp(-c__1))))+4*LambertW(-x*exp(-c__1))*exp(-I*arctanh(exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)/(exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1)-1/(exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1))+(2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)/((1+LambertW(-x*exp(-c__1)))*x*(exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1)^2)

x*exp(arctan(y(x)))-arctan(y(x)) = c__1

0

y(x) = tan(-LambertW(-x*exp(_C2))+_C2)

4*LambertW(-x*exp(c__2))*exp((2*I)*LambertW(-x*exp(c__2))+(2*I)*c__2+I*arctanh(-exp((2*I)*LambertW(-x*exp(c__2)))/(exp((2*I)*LambertW(-x*exp(c__2)))+exp((2*I)*c__2))+exp((2*I)*c__2)/(exp((2*I)*LambertW(-x*exp(c__2)))+exp((2*I)*c__2))))/((exp((2*I)*LambertW(-x*exp(c__2)))+exp((2*I)*c__2))^2*(1+LambertW(-x*exp(c__2)))*x)+4*exp((2*I)*c__2+(2*I)*LambertW(-x*exp(c__2)))/((exp((2*I)*LambertW(-x*exp(c__2)))+exp((2*I)*c__2))^2*(1+LambertW(-x*exp(c__2))))

 

 

 

Third  Try

 

restart;

ode:=1+y(x)^2+(x-exp(-arctan(y(x))))*diff(y(x),x) = 0;
sol_1:=y(x) = -tan(LambertW(-x/exp(_C1))+_C1);
timelimit(30,odetest(sol_1,ode,y(x)));

sol_2:=x*exp(arctan(y(x)))-arctan(y(x)) = _C1;
timelimit(30,odetest(sol_2,ode,y(x)));

sol_3:=y(x) = tan(-LambertW(-x*exp(_C2))+_C2);
timelimit(30,odetest(sol_3,ode,y(x)));

1+y(x)^2+(x-exp(-arctan(y(x))))*(diff(y(x), x)) = 0

y(x) = -tan(LambertW(-x/exp(_C1))+_C1)

4*LambertW(-x*exp(-c__1))*exp(-I*arctanh(exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)/(exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1)-1/(exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1))+(2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)/((1+LambertW(-x*exp(-c__1)))*x*(exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1)^2)+4*exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)/((exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1)^2*(1+LambertW(-x*exp(-c__1))))

x*exp(arctan(y(x)))-arctan(y(x)) = c__1

0

y(x) = tan(-LambertW(-x*exp(_C2))+_C2)

Error, (in depends) too many levels of recursion

 

 

 

4th  Try

 

restart;

ode:=1+y(x)^2+(x-exp(-arctan(y(x))))*diff(y(x),x) = 0;
sol_1:=y(x) = -tan(LambertW(-x/exp(_C1))+_C1);
timelimit(30,odetest(sol_1,ode,y(x)));

sol_2:=x*exp(arctan(y(x)))-arctan(y(x)) = _C1;
timelimit(30,odetest(sol_2,ode,y(x)));

sol_3:=y(x) = tan(-LambertW(-x*exp(_C2))+_C2);
timelimit(30,odetest(sol_3,ode,y(x)));

1+y(x)^2+(x-exp(-arctan(y(x))))*(diff(y(x), x)) = 0

y(x) = -tan(LambertW(-x/exp(_C1))+_C1)

4*LambertW(-x*exp(-c__1))*exp(-I*arctanh(exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)/(exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1)-1/(exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1))+(2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)/((1+LambertW(-x*exp(-c__1)))*x*(exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1)^2)+4*exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)/((exp((2*I)*LambertW(-x*exp(-c__1))+(2*I)*c__1)+1)^2*(1+LambertW(-x*exp(-c__1))))

x*exp(arctan(y(x)))-arctan(y(x)) = c__1

0

y(x) = tan(-LambertW(-x*exp(_C2))+_C2)

4*exp((2*I)*c__2+(2*I)*LambertW(-x*exp(c__2)))/((exp((2*I)*LambertW(-x*exp(c__2)))+exp((2*I)*c__2))^2*(1+LambertW(-x*exp(c__2))))+4*LambertW(-x*exp(c__2))*exp((2*I)*LambertW(-x*exp(c__2))+(2*I)*c__2+I*arctanh(-exp((2*I)*LambertW(-x*exp(c__2)))/(exp((2*I)*LambertW(-x*exp(c__2)))+exp((2*I)*c__2))+exp((2*I)*c__2)/(exp((2*I)*LambertW(-x*exp(c__2)))+exp((2*I)*c__2))))/((exp((2*I)*LambertW(-x*exp(c__2)))+exp((2*I)*c__2))^2*(1+LambertW(-x*exp(c__2)))*x)

 

 

 


 

Download bug_odetest_jan_18_2025.mw

 

 

 

Please Wait...