Question: odetest issues using implicit solution

I think I found another problem with odetest.  When solution is implicit, it fails to verify the solution against the ode when adding the IC. (not everytime, but in some cases).

But it does verify the solution against the ode when IC is not given. I give 3 examples.  Also at bottom is worksheet of all of this.

Example 1

restart;

ode:=diff(y(x), x) = sin(y(x));
ic:=y(0)=Pi/2;
mysol:=ln(tan(y(x)/2))=x;

It says solution satisfies the ode itself OK

odetest(mysol,ode);

gives 0

But adding IC now gives

odetest(mysol,[ode,ic]);

Which I am having hard time reading. Is it now saying the solution does not satisfy the ode or the IC? Both are supposed to be zero.

Are these not supposed to be in same order given? so it looks like if we go left to right, it is saying the solution do not satisfy the ode now but it does satisfy the IC. Right?

But before it said the solution satisfies the ode.

Also, we can see the IC is satisfied. Let do it by hand

eval(mysol,[y(x)=Pi/2,x=0])

              0 = 0

So why does it say solution satisfies the ode first, then when adding the IC, now it changed its mind?

Also, solving for y(x) from the implicit solution, now it verifies it OK  with the IC also:

ode:=diff(y(x), x) = sin(y(x));
ic:=y(0)=Pi/2;
mysol:=ln(tan(y(x)/2))=x;
mysol_explicit:=solve(mysol,y(x));
odetest(y(x)=mysol_explicit,[ode,ic])

          [0, 0]

You see. Same solution. But different result from odetest depending if it is implicit or explicit.

Is this supposed to happen or is this a bug in odetest I should report? odetest is supposed to handle both explicit and implicit solutions. I know my solutions are correct. I just use odetest for verification. I also plotted my solution against maple's solutions and they are exact match. 

Example 2

ode:=diff(y(x),x)=1+y(x)^2;
mysol:=arctan(y(x))=x;
ic:=y(0)=0;
odetest(mysol,ode);
odetest(mysol,[ode,ic]);

Gives 0 for the first call to odetest but gives [diff(y(x), x) - 1 - y(x)^2, 0] for the second call.

Changing the solution to explicit. now it verifies it

mysol_explicit:=solve(mysol,y(x));
odetest(y(x)=mysol_explicit,[ode,ic]);

Now it gives [0,0]

Example 3

ode:=diff(y(x), x) - 2*y(x) = 2*sqrt(y(x));
ic:=y(0)=1;
mysol:=ln(sqrt(y(x))+1)=x+ln(2);
odetest(mysol,ode);
odetest(mysol,[ode,ic]) assuming positive;

Gives for the first call but  [diff(y(x), x) - 2*y(x) - 2*sqrt(y(x)), 0] but when using explicit it now verifies OK

mysol_explicit:=solve(mysol,y(x));
odetest(y(x)=mysol_explicit,[ode,ic]) assuming positive;

           [0, 0]

Maple 2024 on windows 10

23112

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 1751 and is the same as the version installed in this computer, created 2024, May 31, 18:17 hours Pacific Time.`

Example 1

 

restart;

18420

ode:=diff(y(x), x) = sin(y(x));
ic:=y(0)=Pi/2;
mysol:=ln(tan(y(x)/2))=x;
odetest(mysol,ode);

diff(y(x), x) = sin(y(x))

y(0) = (1/2)*Pi

ln(tan((1/2)*y(x))) = x

0

odetest(mysol,[ode,ic]);

[diff(y(x), x)-sin(y(x)), 0]

mysol:=ln(tan(y(x)/2))=x;
mysol_explicit:=solve(mysol,y(x));
odetest(y(x)=mysol_explicit,[ode,ic]);

ln(tan((1/2)*y(x))) = x

2*arctan(exp(x))

[0, 0]

Example 2

 

ode:=diff(y(x),x)=1+y(x)^2;
mysol:=arctan(y(x))=x;
ic:=y(0)=0;
odetest(mysol,ode);

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

arctan(y(x)) = x

y(0) = 0

0

odetest(mysol,[ode,ic]);

[diff(y(x), x)-1-y(x)^2, 0]

mysol_explicit:=solve(mysol,y(x));
odetest(y(x)=mysol_explicit,[ode,ic]);

tan(x)

[0, 0]

Example 3

 

ode:=diff(y(x), x) - 2*y(x) = 2*sqrt(y(x));
ic:=y(0)=1;
mysol:=ln(sqrt(y(x))+1)=x+ln(2);
odetest(mysol,ode);

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

y(0) = 1

ln(y(x)^(1/2)+1) = x+ln(2)

0

odetest(mysol,[ode,ic]) assuming positive;

[diff(y(x), x)-2*y(x)-2*y(x)^(1/2), 0]

mysol_explicit:=solve(mysol,y(x));
odetest(y(x)=mysol_explicit,[ode,ic]) assuming positive;

(2*exp(x)-1)^2

[0, 0]

 

 

Download odetest_implicit_problem_june_2_2024.mw

Please Wait...