nm

11498 Reputation

20 Badges

13 years, 93 days

MaplePrimes Activity


These are questions asked by nm

I gave up on this. I know how to find all normal derivatives such as diff(y(x),x) and diff(y(x),x$2) so on in expression. 

But now I want to find all those used for initial conditions, which do not have x in them. This makes it harder.

These have the form   D(y)(0) or (D@@2)(y)(1) and so on.

I tried indets and select and many other things, but can't figure how to tell Maple to find these in expression. Here is an example.

Given

expr:=y(3)+y(8)+5*(D@@2)(y)(4)+Pi+3*exp(2)+77*D(y)(0)+1/(D@@4)(y)(7);

I'd like to get list that has in it only the derivatives and nothing else, anywhere they show, which will be

{(D@@2)(y)(4) , D(y)(0) , (D@@4)(y)(7) }

some of the things I tried are

indets(expr,'satisfies'(s->op(0,s)=(D@@n)(y) and n::integer) );
indets(expr,'specfunc(anything, D)');
indets(expr,'specfunc(anything, (D@@anything)(y))');

And many more. I still struggle with structured types in Maple.

In the above, we can assume the dependent variable is always same which is the 'y' symbol.

I can do the above using patmatch. But I am trying to move away from that in Maple and use types.

For reference, this is what I do using another software. I am trying to do the same in Maple, but using structured types and not patmatch.

Iam sure there is a way to do this in Maple using structured types, but so far not able to figure the syntax needed.

Maple 2025.1

I have more examples like this. Sometimes odetest give false negative result. dsolve solution is actually correct, but odetest does not return all zeros as result of its checking.

Example 1

interface(version);

`Standard Worksheet Interface, Maple 2025.1, Linux, June 12 2025 Build ID 1932578`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1881 and is the same as the version installed in this computer, created 2025, October 7, 16:4 hours Pacific Time.`

SupportTools:-Version();

`The Customer Support Updates version in the MapleCloud is 29 and is the same as the version installed in this computer, created June 23, 2025, 10:25 hours Eastern Time.`

ode:=x^2*diff(y(x),x)+sin(2*y(x)) = 1;
IC:=y(infinity)=11*Pi/4;
maple_sol:=dsolve([ode,IC]);
odetest(maple_sol,[ode,IC])

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

y(infinity) = (11/4)*Pi

y(x) = -arctan((x+2)/(x-2))+3*Pi

[0, undefined]

#but the IC above should not be undefined. This belows shows it is correct.
limit(maple_sol,x=infinity);

limit(y(x), x = infinity) = (11/4)*Pi

#which is what the IC is.


Download odetest_problem_oct_8_2025.mw

Would you agree that odetest in the above should have returned [0,0] instead? Should this result be considered a bug?

Example 2

More examples where odetest gives false negative. The solution by dsolve is correct but odetest says IC is off but it is not. 

 

interface(version);

`Standard Worksheet Interface, Maple 2025.1, Linux, June 12 2025 Build ID 1932578`

restart;

ode:=x^2*diff(y(x),x)+cos(2*y(x))=1;
IC:=y(infinity)=10/3*Pi;
sol:=dsolve([ode,IC]);

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

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

y(x) = (7/2)*Pi-arctan((1/3)*(3^(1/2)*x+6)/x)

odetest(sol,[ode,IC]);

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

limit(sol,x=infinity);

limit(y(x), x = infinity) = (10/3)*Pi

 


 

Download odetest_problem_oct_11_2025.mw

Example 3

interface(version);

`Standard Worksheet Interface, Maple 2025.1, Linux, June 12 2025 Build ID 1932578`

ode:=x^2*diff(y(x),x)*cos(y(x))+1=0;
IC:=y(infinity)=16/3*Pi;

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

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

sol:=dsolve([ode,IC]);

y(x) = arcsin((1/2)*(3^(1/2)*x-2)/x)+5*Pi

odetest(sol,[ode,IC])

[0, (1/3)*Pi]

limit(sol,x=infinity)

limit(y(x), x = infinity) = (16/3)*Pi

 

 

Download odetest_problem_oct_11_2025_V2.mw

Example 4

interface(version);

`Standard Worksheet Interface, Maple 2025.1, Linux, June 12 2025 Build ID 1932578`

restart;

ode:=diff(y(x),x)*sin(x)-y(x)*cos(x)=-sin(x)^2/x^2;
IC:=y(infinity)=0;

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

y(infinity) = 0

sol:=dsolve([ode,IC]);

y(x) = sin(x)/x

odetest(sol,[ode,IC]);

[0, undefined]

limit(sol,x=infinity)

limit(y(x), x = infinity) = 0

 

 

Download odetest_problem_oct_11_2025_V3.mw

Example 5


 

interface(version);

`Standard Worksheet Interface, Maple 2025.1, Linux, June 12 2025 Build ID 1932578`

restart;

ode:=x*y(x)^2+exp(x)*diff(y(x),x)=0;
IC:=y(infinity)=1/2;
sol:=dsolve([ode,IC]);

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

y(infinity) = 1/2

y(x) = -1/(x*exp(-x)+exp(-x)-2)

odetest(sol,[ode,IC])

[0, undefined]

limit(sol,x=infinity)

limit(y(x), x = infinity) = 1/2

 

 

Download odetest_problem_oct_11_2025_V4.mw

Will add more examples as I find them....

 

Any one could find why dsolve can't solve this first order ode when adding IC,  but Student:-ODEs:-ODESteps can?

interface(version);

`Standard Worksheet Interface, Maple 2025.1, Linux, June 12 2025 Build ID 1932578`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1878 and is the same as the version installed in this computer, created 2025, September 28, 11:35 hours Pacific Time.`

SupportTools:-Version();

`The Customer Support Updates version in the MapleCloud is 29 and is the same as the version installed in this computer, created June 23, 2025, 10:25 hours Eastern Time.`

restart;

ode:=diff(m(t),t) = -k/m(t)^2;
ic:=m(0) = m__0;
DEtools:-odeadvisor(ode);

diff(m(t), t) = -k/m(t)^2

m(0) = m__0

[_quadrature]

sol:=dsolve(ode)

m(t) = (-3*k*t+c__1)^(1/3), m(t) = -(1/2)*(-3*k*t+c__1)^(1/3)-((1/2)*I)*3^(1/2)*(-3*k*t+c__1)^(1/3), m(t) = -(1/2)*(-3*k*t+c__1)^(1/3)+((1/2)*I)*3^(1/2)*(-3*k*t+c__1)^(1/3)

sol:=dsolve([ode,ic])

Student:-ODEs:-ODESteps([ode,ic])

"[[,,"Let's solve"],[,,[(ⅆ)/(ⅆt) m(t)=-k/((m(t))^2),m(0)=`m__0`]],["•",,"Highest derivative means the order of the ODE is" 1],[,,(ⅆ)/(ⅆt) m(t)],["•",,"Solve for the highest derivative"],[,,(ⅆ)/(ⅆt) m(t)=-k/((m(t))^2)],["•",,"Separate variables"],[,,((ⅆ)/(ⅆt) m(t)) (m(t))^2=-k],["•",,"Integrate both sides with respect to" t],[,,∫((ⅆ)/(ⅆt) m(t)) (m(t))^2 ⅆt=∫-k ⅆt+`c__1`],["•",,"Evaluate integral"],[,,((m(t))^3)/3=-k t+`c__1`],["•",,"Solve for" m(t)],[,,{m(t)=(-3 k t+3 `c__1`)^(1/3),m(t)=-((-3 k t+3 `c__1`)^(1/3))/2-(ⅈ sqrt(3) (-3 k t+3 `c__1`)^(1/3))/2,m(t)=-((-3 k t+3 `c__1`)^(1/3))/2+(ⅈ sqrt(3) (-3 k t+3 `c__1`)^(1/3))/2}],["•",,"Simplify"],[,,{m(t)=(-3 k t+3 `c__1`)^(1/3),m(t)=((-3 k t+3 `c__1`)^(1/3) (-1+ⅈ sqrt(3)))/2,m(t)=-((-3 k t+3 `c__1`)^(1/3) (1+ⅈ sqrt(3)))/2}],["•",,"Redefine the integration constant(s)"],[,,{m(t)=(-3 k t+`c__1`)^(1/3),m(t)=((-3 k t+`c__1`)^(1/3) (-1+ⅈ sqrt(3)))/2,m(t)=-((-3 k t+`c__1`)^(1/3) (1+ⅈ sqrt(3)))/2}],["•",,"Use initial condition" m(0)=`m__0`],[,,`m__0`=`c__1`^(1/3)],["•",,"Solve for" `c__1`],[,,`c__1`=`m__0`^3],["•",,"Substitute" `c__1`=`m__0`^3 "into general solution and simplify"],[,,m(t)=(`m__0`^3-3 k t)^(1/3)],["•",,"Use initial condition" m(0)=`m__0`],[,,`m__0`=(`c__1`^(1/3) (-1+ⅈ sqrt(3)))/2],["•",,"Solve for" `c__1`],[,,`c__1`=`m__0`^3],["•",,"Substitute" `c__1`=`m__0`^3 "into general solution and simplify"],[,,m(t)=((`m__0`^3-3 k t)^(1/3) (-1+ⅈ sqrt(3)))/2],["•",,"Use initial condition" m(0)=`m__0`],[,,`m__0`=-(`c__1`^(1/3) (1+ⅈ sqrt(3)))/2],["•",,"Solve for" `c__1`],[,,`c__1`=`m__0`^3],["•",,"Substitute" `c__1`=`m__0`^3 "into general solution and simplify"],[,,m(t)=-((`m__0`^3-3 k t)^(1/3) (1+ⅈ sqrt(3)))/2],["•",,"Solutions to the IVP"],[,,[m(t)=(`m__0`^3-3 k t)^(1/3),m(t)=((`m__0`^3-3 k t)^(1/3) (-1+ⅈ sqrt(3)))/2,m(t)=-((`m__0`^3-3 k t)^(1/3) (1+ⅈ sqrt(3)))/2]]]"

Download why_dsolve_cant_solve_ode_oct_4_2025_maple_2025_1.mw

Given an ode with IC. When solution is explicit, Maple resolves the constant of integration as expected and returns solution with no c__1 in it.

But when asked for implicit solution, also with same IC, it now returns solution with c__1 still there.

Is this by design or a bug? Should not constant of integration be resolved using IC in both cases? If unable to solve for c__1 because solution is implicit, should it then not return solution all?

Does this happen in earlier versions of Maple?

 

restart;

interface(version);

`Standard Worksheet Interface, Maple 2025.1, Linux, June 12 2025 Build ID 1932578`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1878 and is the same as the version installed in this computer, created 2025, September 28, 11:35 hours Pacific Time.`

SupportTools:-Version();

`The Customer Support Updates version in the MapleCloud is 29 and is the same as the version installed in this computer, created June 23, 2025, 10:25 hours Eastern Time.`

restart;

IC:=D(y)(0)=0;
ode:=diff(y(x),x)^2+x*y(x)=0:
sol:=dsolve([ode,IC]);

 

(D(y))(0) = 0

y(x) = 0, y(x) = -(1/9)*x^3

sol:=dsolve(ode,'implicit');

y(x) = 0, -x^2/((x^3+9*y(x))*(x^2+3*(-x*y(x))^(1/2)))+3*(-x*y(x))^(1/2)/((x^3+9*y(x))*(x^2+3*(-x*y(x))^(1/2)))-c__1 = 0, x^2/((x^3+9*y(x))*(-x^2+3*(-x*y(x))^(1/2)))+3*(-x*y(x))^(1/2)/((x^3+9*y(x))*(-x^2+3*(-x*y(x))^(1/2)))-c__1 = 0

#WHY did not resolve constant of integration here??
sol:=dsolve([ode,IC],'implicit');

x^2/((x^3+9*y(x))*(-x^2+3*(-x*y(x))^(1/2)))+3*(-x*y(x))^(1/2)/((x^3+9*y(x))*(-x^2+3*(-x*y(x))^(1/2)))-c__1 = 0, -x^2/((x^3+9*y(x))*(x^2+3*(-x*y(x))^(1/2)))+3*(-x*y(x))^(1/2)/((x^3+9*y(x))*(x^2+3*(-x*y(x))^(1/2)))-c__1 = 0, y(x) = 0

 


 

Download why_C_still_in_solution_maple_2025_1_oct_4_2025.mw

I looked at help for PDEtools:-Solve and do not see why this would fail. Any idea? Is this by design or could it be a bug?  solve() works on same input, so I expected Solve to also work on same input.

interface(version);

`Standard Worksheet Interface, Maple 2025.1, Linux, June 12 2025 Build ID 1932578`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1878 and is the same as the version installed in this computer, created 2025, September 28, 11:35 hours Pacific Time.`

SupportTools:-Version();

`The Customer Support Updates version in the MapleCloud is 29 and is the same as the version installed in this computer, created June 23, 2025, 10:25 hours Eastern Time.`

restart;

eq:=D(y)(0)+1 = 0;
solve(eq,D(y)(0));

(D(y))(0)+1 = 0

-1

PDEtools:-Solve(eq,D(y)(0));

Error, (in PDEtools:-Solve) required an indication of the solving variables for the given system

 

 

Download why_PDEtools_Sovle_fail_oct_3_2025.mw

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