Question: why order of odetest makes difference in how it works?

I think I just found one of the most serious problems in Maple I've seen (other than timelimit hanging).

This is using Maple 2024.2 on windows 10.

I'll explain in words the problem, then give worksheet below to reproduce this. I can reproduce this all the time.

I have implicit solution in y(x) to an ode.

If I first solve for y(x) from the solution, so solution is now explicit, then call odetest to check if this explicit solution is correct, and if I use assumptions on the odetest call, and then after that call odetest on the original implicit solution, then odetest fails to verify the implicit solution.

But, if I change the order, and first call odetest to verify the implicit solution first, it verifies it OK !  

So the problem ONLY happens if I change the order of calling odetest and if I use assumptions on the odetest call that was used before on the explicit solution.

This tells me that Maple remembers something from earlier call. Does it remember the assumptions used? If so, this is very risky. As some part of program might call odetest with some assumptions, and another part of the program can use no assumptions.  I thought assuming is only applied to the call it is used at only and will not affect future calls.

Is there a way then to clear all assumptions used on earlier call to Maple command before using the command again? Or to tell Maple not to remember assumptions used on a call?

This is a big problem. It took me 14 hrs of debuging to find it. Order of calls to odetest should not make it behave different.

I hope someone could find solution to this, since now I have no idea what to do as I need to use odetest on explicit and implicit solutions and I do not want the order of calling Maple command to make difference in results.

This worksheet shows the problem. 3 cases are given. Notice that when using assumptions on earlier call to odetest, how it fails to verify the implicit solution in later call.

restart;

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 1824 and is the same as the version installed in this computer, created 2024, October 31, 14:22 hours Pacific Time.`

kernelopts('assertlevel'=2):

CASE 1. Calling odetest on explicit first with assumptions, make odetest hang when calling on implicit after

 

restart;

IMPLICIT_SOL:=ln(10*x^2 + (10*y(x) + 12)*x + 5*y(x)^2 + 8*y(x) + 4)/5 - (4*arctan((5*y(x) + 5*x + 4)/(5*x + 2)))/5 = (3*ln(2))/5 + (4*arctan(3))/5;
ode:=2*x+3*y(x)+2+(y(x)-x)*diff(y(x),x) = 0;
IC:=y(0) = -2;

(1/5)*ln(10*x^2+(10*y(x)+12)*x+5*y(x)^2+8*y(x)+4)-(4/5)*arctan((5*y(x)+5*x+4)/(5*x+2)) = (3/5)*ln(2)+(4/5)*arctan(3)

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

y(0) = -2

#find explicit solution first
EXPLICIT_SOL:=solve(IMPLICIT_SOL,y(x)):

#NOw check the explicit solution. Using assumptions to see the problem
timelimit(30,  ( odetest(y(x)=EXPLICIT_SOL,[ode,IC]) assuming positive, y(x)::positive) );

Error, (in evalr) time expired

#Now odetest hangs on the implicit solution

timelimit(30,  odetest(IMPLICIT_SOL,[ode,IC]) );

Error, (in is/internal/rename) time expired

 

 

(1/5)*ln(10*x^2+(10*y(x)+12)*x+5*y(x)^2+8*y(x)+4)-(4/5)*arctan((5*y(x)+5*x+4)/(5*x+2)) = (3/5)*ln(2)+(4/5)*arctan(3)

y(x)

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

y(0) = -2

CASE 2. Calling odetest on implicit solution first, then it DOES NOT hang !!

 

restart;

IMPLICIT_SOL:=ln(10*x^2 + (10*y(x) + 12)*x + 5*y(x)^2 + 8*y(x) + 4)/5 - (4*arctan((5*y(x) + 5*x + 4)/(5*x + 2)))/5 = (3*ln(2))/5 + (4*arctan(3))/5;
ode:=2*x+3*y(x)+2+(y(x)-x)*diff(y(x),x) = 0;
IC:=y(0) = -2;

(1/5)*ln(10*x^2+(10*y(x)+12)*x+5*y(x)^2+8*y(x)+4)-(4/5)*arctan((5*y(x)+5*x+4)/(5*x+2)) = (3/5)*ln(2)+(4/5)*arctan(3)

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

y(0) = -2

#notice, no hang now, since called before
timelimit(30,  odetest(IMPLICIT_SOL,[ode,IC]) );

[0, 0]

#NOw check the explicit solution. This will timeout which is OK
EXPLICIT_SOL:=solve(IMPLICIT_SOL,y(x)):
timelimit(30,  ( odetest(y(x)=EXPLICIT_SOL,[ode,IC]) assuming positive, y(x)::positive) );

Error, (in type/complex) time expired

#check again that odetest still verifies the implicit solution OK

timelimit(30,  odetest(IMPLICIT_SOL,[ode,IC]) );

[0, 0]

 

CASE 3. Calling odetest with no assumptions on explicit solution, then it also does not hang

 

restart;

IMPLICIT_SOL:=ln(10*x^2 + (10*y(x) + 12)*x + 5*y(x)^2 + 8*y(x) + 4)/5 - (4*arctan((5*y(x) + 5*x + 4)/(5*x + 2)))/5 = (3*ln(2))/5 + (4*arctan(3))/5;
ode:=2*x+3*y(x)+2+(y(x)-x)*diff(y(x),x) = 0;
IC:=y(0) = -2;

(1/5)*ln(10*x^2+(10*y(x)+12)*x+5*y(x)^2+8*y(x)+4)-(4/5)*arctan((5*y(x)+5*x+4)/(5*x+2)) = (3/5)*ln(2)+(4/5)*arctan(3)

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

y(0) = -2

#Now check the explicit solution. but DO NOT use assumptions
EXPLICIT_SOL:=solve(IMPLICIT_SOL,y(x)):
timelimit(30, odetest(y(x)=EXPLICIT_SOL,[ode,IC]));

Error, (in factor/remember) time expired

#check again that odetest still verifies the implicit solution OK

timelimit(30,  odetest(IMPLICIT_SOL,[ode,IC]) );

[0, 0]

 


 

Download order_of_ode_test_makes_difference_oct_31_2024.mw

 

update NOV 2, 2024 6 AM

I found the cause.

Removing PHYSICS from libname, then the problem goes away !

So this is caused by PHYSICS package. For some reason, having Physics package in the libname causes odetest to hang/fail compared to when the physics package is not in the libname path. Worksheet below.

restart;

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 1824 and is the same as the version installed in this computer, created 2024, October 31, 14:22 hours Pacific Time.`

libname;

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

CASE 1. without PHYSICS on libname, it works !!

 

restart;

kernelopts('assertlevel'=2):

libname;

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

libname:=libname[2]; #remove PHYSICS

"C:\Program Files\Maple 2024\lib"

libname;

"C:\Program Files\Maple 2024\lib"

IMPLICIT_SOL:=ln(10*x^2 + (10*y(x) + 12)*x + 5*y(x)^2 + 8*y(x) + 4)/5 - (4*arctan((5*y(x) + 5*x + 4)/(5*x + 2)))/5 = (3*ln(2))/5 + (4*arctan(3))/5;
ode:=2*x+3*y(x)+2+(y(x)-x)*diff(y(x),x) = 0;
IC:=y(0) = -2;

(1/5)*ln(10*x^2+(10*y(x)+12)*x+5*y(x)^2+8*y(x)+4)-(4/5)*arctan((5*y(x)+5*x+4)/(5*x+2)) = (3/5)*ln(2)+(4/5)*arctan(3)

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

y(0) = -2

#find explicit solution first
EXPLICIT_SOL:=solve(IMPLICIT_SOL,y(x)):

#NOw check the explicit solution. Using assumptions to see the problem
timelimit(30,  ( odetest(y(x)=EXPLICIT_SOL,[ode,IC]) assuming positive, y(x)::positive) );

Error, (in evalr/ln) time expired

#Now try odetest  on the implicit solution

infolevel[odetest]:=5;

5

timelimit(30,  odetest(IMPLICIT_SOL,[ode,IC]) );

odetest: Performing an implicit solution test

odetest: Performing an explicit (try soft) solution test

odetest: Performing an implicit solution (II) test

[0, 0]

 

 

CASE 2. With Physics on libname, it fails !

 

restart;

kernelopts('assertlevel'=2):

libname;

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

IMPLICIT_SOL:=ln(10*x^2 + (10*y(x) + 12)*x + 5*y(x)^2 + 8*y(x) + 4)/5 - (4*arctan((5*y(x) + 5*x + 4)/(5*x + 2)))/5 = (3*ln(2))/5 + (4*arctan(3))/5;
ode:=2*x+3*y(x)+2+(y(x)-x)*diff(y(x),x) = 0;
IC:=y(0) = -2;

(1/5)*ln(10*x^2+(10*y(x)+12)*x+5*y(x)^2+8*y(x)+4)-(4/5)*arctan((5*y(x)+5*x+4)/(5*x+2)) = (3/5)*ln(2)+(4/5)*arctan(3)

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

y(0) = -2

#find explicit solution first
EXPLICIT_SOL:=solve(IMPLICIT_SOL,y(x)):

timelimit(30,  ( odetest(y(x)=EXPLICIT_SOL,[ode,IC]) assuming positive, y(x)::positive) );

Error, (in evalr/shake) time expired

#Now try odetest  on the implicit solution

infolevel[odetest]:=5;

5

timelimit(30,  odetest(IMPLICIT_SOL,[ode,IC]) );

odetest: Performing an implicit solution test

odetest: Performing an explicit (try soft) solution test

odetest: Performing an implicit solution (II) test

Error, (in is/internal/rename) time expired

 

 

Download order_of_ode_test_makes_difference_NOV_2_2024.mw

my question is: Is it safe to permanently remove Physics package from libname? Why is having physics package in libname (which is by default) causes this problem?

I do not use Physics package explicitly in my code. i.e. I do not do Physics:- calls. 

Any one knows what effect not having Physics on libname cause? Will Maple still work OK for everything if one is not calling Physics package explicitly?

Please Wait...