nm

11353 Reputation

20 Badges

13 years, 12 days

MaplePrimes Activity


These are questions asked by nm

odetest should be made more robust.

Here is an example where the same exact solution and same exact IC, but when solution is just writtent in a  little different form, odetest no longer verifies it.

Do you consider this a bug? How is the user supposed to know their solution is correct or not now, since it depends on how it is written? What can a user then do to help odetest in this case verify the solution?


 

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

ode:=diff(y(x), x)*x^2 + cos(2*y(x)) = 1;
ic:=y(infinity)=10/3*Pi;
e1:=2/x+1/3*sqrt(3);
SOL1:=y(x)=arccot(e1) + Pi*3;
odetest(SOL1,[ode,ic]);

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

y(infinity) = (10/3)*Pi

2/x+(1/3)*3^(1/2)

y(x) = arccot(2/x+(1/3)*3^(1/2))+3*Pi

[0, 0]

#now we rewrite the solution a little different. But same solution
e2:=simplify(e1);

(1/3)*(3^(1/2)*x+6)/x

#Now maple no longer verifies the solution

SOL2:=y(x)=arccot(e2) + Pi*3;
odetest(SOL2,[ode,ic])

y(x) = arccot((1/3)*(3^(1/2)*x+6)/x)+3*Pi

[0, -(1/6)*Pi]

 


 

Download same_solution_not_verified_june_13_2024.mw

Maple gives same solution for two different equations.

eq1 := 1/5*sqrt(-20*y + 1) - 1/5*ln(1 + sqrt(-20*y + 1)) = x + 2;
eq2 := -1/5*sqrt(-20*y + 1) - 1/5*ln(1 - sqrt(-20*y + 1)) = x + 2;

Solving these for y, gives same exact solution. But this is not correct. As this worksheet shows.

Is this a bug? How could two different equations give same solution?
 

15172

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Case 1. Solve first then plugin x value in solution

 

eq1:=(sqrt(a^2 - 4*b*y) - a*ln(a + sqrt(a^2 - 4*b*y)))/b=x+c__1;
eq2:=(-sqrt(a^2 - 4*b*y) - a*ln(a - sqrt(a^2 - 4*b*y)))/b=x+c__1;

eq1:=eval(eq1,[a=1,b=5,c__1=2]);
eq2:=eval(eq2,[a=1,b=5,c__1=2]);

((a^2-4*b*y)^(1/2)-a*ln(a+(a^2-4*b*y)^(1/2)))/b = x+c__1

(-(a^2-4*b*y)^(1/2)-a*ln(a-(a^2-4*b*y)^(1/2)))/b = x+c__1

(1/5)*(-20*y+1)^(1/2)-(1/5)*ln(1+(-20*y+1)^(1/2)) = x+2

-(1/5)*(-20*y+1)^(1/2)-(1/5)*ln(1-(-20*y+1)^(1/2)) = x+2

sol1:=simplify(solve(eq1,y));

-(1/20)*LambertW(-exp(-11-5*x))*(LambertW(-exp(-11-5*x))+2)

sol2:=simplify(solve(eq2,y));

-(1/20)*LambertW(-exp(-11-5*x))*(LambertW(-exp(-11-5*x))+2)

eval(sol1,x=10.);

0.3221340286e-27

eval(sol2,x=10.);

0.3221340286e-27

Case 2. Plugin in same x value in equation and then solve, we get different answers

 

eq1:=(sqrt(a^2 - 4*b*y) - a*ln(a + sqrt(a^2 - 4*b*y)))/b=x+c__1;
eq2:=(-sqrt(a^2 - 4*b*y) - a*ln(a - sqrt(a^2 - 4*b*y)))/b=x+c__1;

eq1:=eval(eq1,[a=1,b=5,c__1=2,x=10]);
eq2:=eval(eq2,[a=1,b=5,c__1=2,x=10]);

((a^2-4*b*y)^(1/2)-a*ln(a+(a^2-4*b*y)^(1/2)))/b = x+c__1

(-(a^2-4*b*y)^(1/2)-a*ln(a-(a^2-4*b*y)^(1/2)))/b = x+c__1

(1/5)*(-20*y+1)^(1/2)-(1/5)*ln(1+(-20*y+1)^(1/2)) = 12

-(1/5)*(-20*y+1)^(1/2)-(1/5)*ln(1-(-20*y+1)^(1/2)) = 12

sol1:=evalf(solve(eq1,y));

-205.8850616

sol2:=evalf(solve(eq2,y));

0.3221340286e-27


 

Download different_equations_give_same_solution_june_12_2024.mw

 

These are two examples of challenging ode solutions to show they satisfy the ode.

I tried many things myself but can't do it. Feel free to use any method or trick you want. The goal is simply to show that the solution is correct. The solutions are correct as far as I know, but hard to show by back substitution since the solutions are given in form of integrals and RootOf in them.

Extra credit points will be awarded for those who manage to do both.

28148

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Example 1

 

_EnvTry:='hard';
ode:=y(x) = arcsin(diff(y(x), x)) + ln(1 + diff(y(x), x)^2);
sol:=dsolve(ode);
r:=odetest(sol,ode);
coulditbe(r=0);

hard

y(x) = arcsin(diff(y(x), x))+ln(1+(diff(y(x), x))^2)

x-Intat(1/sin(RootOf(-_a+_Z+ln(sin(_Z)^2+1))), _a = y(x))-c__1 = 0

-arcsin(sin(RootOf(-y(x)+_Z+ln(3/2-(1/2)*cos(2*_Z)))))+RootOf(-y(x)+_Z+ln(3/2-(1/2)*cos(2*_Z)))

FAIL

Example 2

 

ode:=(1 + diff(y(x), x)^2)*(arctan(diff(y(x), x)) + a*x) + diff(y(x), x) = 0;
sol:=dsolve(ode);
r:=odetest(sol,ode);
coulditbe(r=0)

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

y(x) = Int(tan(RootOf(a*x*tan(_Z)^2+tan(_Z)^2*_Z+a*x+tan(_Z)+_Z)), x)+c__1

(-arctan(tan(RootOf(2*a*x+sin(2*_Z)+2*_Z)))+RootOf(2*a*x+sin(2*_Z)+2*_Z))*tan(RootOf(2*a*x+sin(2*_Z)+2*_Z))/(a*x+RootOf(2*a*x+sin(2*_Z)+2*_Z))

FAIL

 

 

Download showing_solution_satisfies_ode.mw

How to make Maple simplify a/sqrt(tan(x+c__1)^2+1); to a/sqrt(sec(x+c__1)^2);  ?

Below is worksheet. since the second one is smaller in leaf size, expected simplify(...,size) to do it, But it did not. Any suggestions?

24832

LC:=MmaTranslator:-Mma:-LeafCount;
e1:=a/sqrt(tan(x+c__1)^2+1);
e2:=a/sqrt(sec(x+c__1)^2);

MmaTranslator:-Mma:-LeafCount

a/(tan(x+c__1)^2+1)^(1/2)

a/(sec(x+c__1)^2)^(1/2)

LC(e1);

12

LC(e2);

10

#we see they are same
simplify(e1-e2);

0

#both nothing below make e1 to e2
simplify(e1); #not good simplification at all. Adds csgn.
LC(%);

a*csgn(sec(x+c__1))*cos(x+c__1)

11

#expected this to do it but no
simplify(e1,size);
LC(%);

a/(tan(x+c__1)^2+1)^(1/2)

12

simplify(e1,trig);

a/(tan(x+c__1)^2+1)^(1/2)

combine(e1,trig);

a/(tan(x+c__1)^2+1)^(1/2)

 


Using some other software:

 

 

 

Download tan_sec_simplification_june_9_2024.mw

I was trying to find out why my solution was not validating for this ode. It turned out because I was using solve instead of PDEtools:-Solve. It took me sometime to find this.

This made huge difference on odetest to verify the solution.

This is very simple ode. We just need to integrate once. But first we have to solve for y'(x). 

And here comes the difference. When I used solve to solve for y'(x), odetest did not verify the solution.

When using PDEtools:-Solve, it did.

The difference is how each returned the solution for y'(x). Both have RootOf but written differently and this made the difference.

1) Why solutions are written differently? 

2) Is this to be expected? I have thought Solve uses same engine as solve below the cover.

3) is it possible to make solve give the same form as Solve or change to that form?

I am now changing more of my code to use PDEtools:-Solve because of this.

27860

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1757. The version installed in this computer is 1756 created 2024, June 5, 19:39 hours Pacific Time, found in the directory C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib\`

Using solve

 

restart;

27860

ode:=x-ln(diff(y(x),x))-sin(diff(y(x),x))=0;
RHS:=solve(ode,diff(y(x),x));

x-ln(diff(y(x), x))-sin(diff(y(x), x)) = 0

RootOf(_Z-exp(-sin(_Z)+x))

mysol:= y(x) = Int(RHS,x)+c__1;

y(x) = Int(RootOf(_Z-exp(-sin(_Z)+x)), x)+c__1

odetest(mysol,ode);

-ln(RootOf(_Z-exp(-sin(_Z)+x)))+x-sin(RootOf(_Z-exp(-sin(_Z)+x)))

using PDEtools:-Solve (now it verifies) with no extra effort

 

restart;

27860

ode:=x-ln(diff(y(x),x))-sin(diff(y(x),x))=0;
RHS:=PDEtools:-Solve(ode,diff(y(x),x)):
RHS:=rhs(%);

x-ln(diff(y(x), x))-sin(diff(y(x), x)) = 0

RootOf(-x+ln(_Z)+sin(_Z))

mysol:= y(x) = Int(RHS,x)+c__1;

y(x) = Int(RootOf(-x+ln(_Z)+sin(_Z)), x)+c__1

odetest(mysol,ode);

0

 

 

Download PDEtools_Solve_vs_solve_june_8_2024.mw

 

Update

Here is a counter example. Where now it is the other way around.

Using solve makes odetest happy, but when using PDEtools:-Solve odetest does not verify the solution.  Same exact ODE.   


 

28652

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version()

`The "Physics Updates" version in the MapleCloud is 1757 and is the same as the version installed in this computer, created 2024, June 6, 14:53 hours Pacific Time.`

Example, using solve works

 

ode:=exp(diff(y(x), x) - y(x)) - diff(y(x), x)^2 + 1 = 0;
RHS:=solve(ode,diff(y(x),x));
RHS:=eval(RHS,y(x)=y);
mysol:=Intat(eval(1/RHS,y=_a),_a=y(x))=x+c__1;
odetest(mysol,ode);

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

Warning, solutions may have been lost

RootOf(-exp(_Z-y(x))+_Z^2-1)

RootOf(-exp(_Z-y)+_Z^2-1)

Intat(1/RootOf(-exp(_Z-_a)+_Z^2-1), _a = y(x)) = x+c__1

0

Example, using PDEtools:-Solve fails

 

ode:=exp(diff(y(x), x) - y(x)) - diff(y(x), x)^2 + 1 = 0;
RHS:=rhs(PDEtools:-Solve(ode,diff(y(x),x)));
RHS:=eval(RHS,y(x)=y);
mysol:=Intat(eval(1/RHS,y=_a),_a=y(x))=x+c__1;
odetest(mysol,ode);

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

RootOf(_Z^2*exp(y(x))-exp(_Z)-exp(y(x)))

RootOf(_Z^2*exp(y)-exp(_Z)-exp(y))

Intat(1/RootOf(_Z^2*exp(_a)-exp(_Z)-exp(_a)), _a = y(x)) = x+c__1

exp(RootOf(_Z^2*exp(y(x))-exp(_Z)-exp(y(x)))-y(x))-RootOf(_Z^2*exp(y(x))-exp(_Z)-exp(y(x)))^2+1

 


 

Download PDEtools_Solve_vs_solve_june_9_2024.mw

So now I have no idea which to use. Sometimes solve works and sometimes Solve works. I  guess I have to now solve the ode both ways each time and see which works.

 

First 27 28 29 30 31 32 33 Last Page 29 of 199