nm

10476 Reputation

19 Badges

12 years, 207 days

MaplePrimes Activity


These are questions asked by nm

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

sometimes I need to check if an ode is missing y(x) or not. Since diff(y(x),x) has y(x) in it, then can not just check if the ode has y(x) or not as is, as this will always gives true if diffy(y(x),x) is there of any order.

Currently what I do, is change all y',y'',y''', etc... to Z,Z^2,Z^3,etc... and then after that it is safe to check if y(x) exist or not.

Is there a better way to do this? Below is what I currently do and it works. Just wondering if there could a more elgent way to do this.

restart;

interface(version);

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

ode:=y(x)*diff(y(x),x$2)^2+diff(y(x),x$3)+y(x)*sqrt(diff(y(x),x))+3*x+3=1/(x*y(x)*diff(y(x),x$5));
ode_order := Student:-ODEs:-DifferentialOrder(ode,y(x)):
ode:=convert(ode,D):
for N from 1 to ode_order do
    ode:=eval(ode,[(D@@N)(y)(x)=Z^N]);
od:
ode

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

y(x)*Z^4+Z^3+y(x)*Z^(1/2)+3*x+3 = 1/(x*y(x)*Z^5)

has(ode,y(x))

true

 

 

Download find_if_any_ode_has_yx_jan_6_2025.mw

I found that convert(ode,y_x) converts the input ode, when it is NOT an equation, to an equation.  

sometimes and sometimes not.

For example,  convert(diff(y(t),t)+y(t)-t,y_x)  gives diff(t(y), y) = 1/(t(y) - y) 

Notice the input is not an equation. Maple adds = and makes an equation in the output. 

This can cause no problem if it works like this in all cases. But if the input has piecewise, then Maple no longer does the same and keep the output as not an equation.

I found this by accident, as my code was doing lhs() on the result of convert, and that always worked, except when I used an ode with piecewise.

This behaviour is not consistent. Maple should either always convert output to equation for all input or not convert. It should not do it for some input and not the other.

Actually, the best behaviour is for the software to reject the input in first place if it is not an equation.

Worksheet below.

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"

#this works even when there is no equation in input, but the result is equation
ode:=diff(y(t),t)+y(t)-t;
convert(ode,y_x,y(t))

diff(y(t), t)+y(t)-t

diff(t(y), y) = 1/(t(y)-y)

ode:=diff(y(t),t)+y(t)-t=0; #this gives same result as above.
convert(ode,y_x,y(t))

diff(y(t), t)+y(t)-t = 0

diff(t(y), y) = 1/(t(y)-y)

#but now if the input is not equation, the output is not equation. Why
#did it not do the same as above??
ode:=diff(y(t),t)+y(t)-piecewise(0<=t and t<=1,2,t>1,0);
convert(ode,y_x,y(t))

ode := diff(y(t), t)+y(t)-piecewise(0 <= t and t <= 1, 2, 1 < t, 0)

1/(diff(t(y), y))+y-piecewise(0 <= t(y) and t(y) <= 1, 2, 1 < t(y), 0)

 

 

Download strange_behaviour_of_convert_yx_jan_5_20225.mw

For plotting phase plot of two system of equations (autonomous), is there an option to increase of reduce number of arrows/line drawn?  I am not able to find such an option from help.

Below is an example. Google AI says stepsize should change the number of arrows, but it does not. It had no effect. Below is worksheet showing one example where I like to reduce number of arrows (not the size of the arrow, which is set to medium now).

I also tried numpoints option and it had no effect of how many arrows are drawn

interface(version);

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

the_sys:=[diff(x(t),t) = -3*x(t)-4*y(t), diff(y(t),t) = 2*x(t)+y(t)]:
DEtools:-DEplot(the_sys,[x(t), y(t)],t =0 .. 10,x = -4 .. 4,y = -4 .. 4,'labels' = [x(t),y(t)],'axes' = 'boxed', 'arrows'='medium')

 

 

Download change_number_of_arrows_jan_4_2025.mw

For reference, I'd like to do something similar using another system as below where it has option to change number of arrows.

something I always wondered about. On Maple website it says

Notice the date above., December 26.

On my Maple, with latest update, same version is printed, but the date is way off.

It says December 2, not 26.

Why is that? Should not the date be the same sicne same version 1840 of Physics update?

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 1840 and is the same as the version installed in this computer, created 2024, December 2, 10:11 hours Pacific Time.`

 

 

Download physics_version.mw

1 2 3 4 5 6 7 Last Page 3 of 190