nm

11518 Reputation

20 Badges

13 years, 103 days

MaplePrimes Activity


These are questions asked by nm

Solving an ode, dsolve says it used exact method and gives two solutions as result (correct result).

But when asking dsolve to solve same ode but now specifying that it uses exact method (i.e. same one it used itself before), now it gives one solution only, not two as before.

Why is that? Should not both commands give same result? i.e. two solutions?

interface(version);

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

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.`

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.`

restart;

ode:=3*y(x)^3*x^2+y(x)^4+(3*x^3*y(x)^2+y(x)^4+4*x*y(x)^3)*diff(y(x),x) = 0;
DEtools:-odeadvisor(ode);
infolevel[dsolve]:=5:

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

[_exact, _rational]

sol:=dsolve(ode); #gives two solutions

Classification methods on request

Methods to be used are: [exact]

----------------------------

* Tackling ODE using method: exact

--- Trying classification methods ---

trying exact

<- exact successful

y(x) = 0, x*y(x)^4+x^3*y(x)^3+(1/5)*y(x)^5+c__1 = 0

maple_sol:=dsolve(ode,[exact]);  #why y=0 solution do not show here??

Classification methods on request

Methods to be used are: [exact]

----------------------------

* Tackling ODE using method: exact

--- Trying classification methods ---

trying exact

<- exact successful

x*y(x)^4+x^3*y(x)^3+(1/5)*y(x)^5+c__1 = 0

sol:=dsolve(ode); #gives two solutions again

Classification methods on request

Methods to be used are: [exact]

----------------------------

* Tackling ODE using method: exact

--- Trying classification methods ---

trying exact

<- exact successful

y(x) = 0, x*y(x)^4+x^3*y(x)^3+(1/5)*y(x)^5+c__1 = 0

 

 

Download why_different_solutions_maple_2025_1_oct_22_2025.mw

Just found strange bug in Maple. 

If I do solve(eq1...) then solve(eq2,...) then the second solve now gives internal error.

But If I do (from clean start)  just solve(eq2,...) then it times out ok, No internal error. So clearly the first call to solve changed something in internal memory/cache to do this.

Is there a way to correctly "clear" solve cache or its memory tables after each call, so that earlier calls to solve do not affect future calls behavior? Was going to add this to my collection of maple bugs post, but thought a new question will be better to make it easier to reply.

The problem is that these internal Maple errors can not be cought by try/catch. Which means the whole program crashes and there is no way to continue automatically.

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 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.`

solve timesout OK if no call made before it

 

restart;

kernelopts('assertlevel'=2):

eq_2:=1 = -X*((1/2/(2*X*Y*a+2*X*a*y0+2*Y*a*x0+2*a*x0*y0-Y^2-2*Y*y0-y0^2)^(1/2)*Y*(2*Y
*a+2*a*y0)+1/2/(2*X*Y*a+2*X*a*y0+2*Y*a*x0+2*a*x0*y0-Y^2-2*Y*y0-y0^2)^(1/2)*y0*(
2*Y*a+2*a*y0))/(-2*X*Y*a-2*X*a*y0-2*Y*a*x0-2*a*x0*y0+Y^2+2*Y*y0+a^2+y0^2)-(-a*Y
-a*y0+(2*X*Y*a+2*X*a*y0+2*Y*a*x0+2*a*x0*y0-Y^2-2*Y*y0-y0^2)^(1/2)*Y+(2*X*Y*a+2*
X*a*y0+2*Y*a*x0+2*a*x0*y0-Y^2-2*Y*y0-y0^2)^(1/2)*y0)/(-2*X*Y*a-2*X*a*y0-2*Y*a*
x0-2*a*x0*y0+Y^2+2*Y*y0+a^2+y0^2)^2*(-2*Y*a-2*a*y0))/Y/((-a+1/2/(2*X*Y*a+2*X*a*
y0+2*Y*a*x0+2*a*x0*y0-Y^2-2*Y*y0-y0^2)^(1/2)*Y*(2*X*a+2*a*x0-2*Y-2*y0)+(2*X*Y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*x0*y0+Y^2+2*Y*y0+a^2+y0^2)-(-a*Y-a*y0+(2*X*Y*a+2*X*a*y0+2*Y*a
*x0+2*a*x0*y0-Y^2-2*Y*y0-y0^2)^(1/2)*Y+(2*X*Y*a+2*X*a*y0+2*Y*a*x0+2*a*x0*y0-Y^2
-2*Y*y0-y0^2)^(1/2)*y0)/(-2*X*Y*a-2*X*a*y0-2*Y*a*x0-2*a*x0*y0+Y^2+2*Y*y0+a^2+y0
^2)^2*(-2*X*a-2*a*x0+2*Y+2*y0)):
try
    timelimit(30,solve(identity(eq_2,X),[x0,y0]));
catch:
    print("good. No crash");
end try;

Error, (in is/duplicates:-Normal) too many levels of recursion

 

 

Download second_sovle_fail_maple_2025_1_oct_21_2025.mw

When solution was obtained using earlier call to solve with _EnvAllSolutions := true: set, then odetest givens internal error.

When _EnvAllSolutions := false: then no error.

Why? And is there a workaround so I can use _EnvAllSolutions := true: but have odetest still work?

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.`

 

Example fail when using _EnvAllSolutions := true:

 

restart;

kernelopts('assertlevel'=2):

ode:=diff(y(x),x) = ln(1+y(x)^2);
IC:=y(0)=0;
x0:=0;
sol:=y(x) = -sqrt(-1 + exp(RootOf(-Intat(-1/(2*tau*sqrt(-1 + exp(tau))*exp(-tau)), tau = _Z) + x + _C2)));

eq:=0=eval(rhs(sol),x=x0);
_EnvAllSolutions := true:
_EnvExplicit := true:
sol_C:=_C2=solve(eq,_C2);
sol:=eval(sol,sol_C);
odetest(%,[ode,IC])

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

y(0) = 0

0

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

0 = -(-1+exp(RootOf(-Intat(-(1/2)/(tau*(-1+exp(tau))^(1/2)*exp(-tau)), tau = _Z)+_C2)))^(1/2)

_C2 = Intat(-(1/2)*exp(tau)/(tau*(-1+exp(tau))^(1/2)), tau = (2*I)*Pi*_Z1)

y(x) = -(-1+exp(RootOf(-Intat(-(1/2)/(tau*(-1+exp(tau))^(1/2)*exp(-tau)), tau = _Z)+x+Intat(-(1/2)*exp(tau)/(tau*(-1+exp(tau))^(1/2)), tau = (2*I)*Pi*_Z1))))^(1/2)

Error, (in series/csgn) assertion failed

 

Example Works  when using _EnvAllSolutions := false:

 

restart;

kernelopts('assertlevel'=2):

ode:=diff(y(x),x) = ln(1+y(x)^2);
IC:=y(0)=0;
x0:=0;
sol:=y(x) = -sqrt(-1 + exp(RootOf(-Intat(-1/(2*tau*sqrt(-1 + exp(tau))*exp(-tau)), tau = _Z) + x + _C2)));

eq:=0=eval(rhs(sol),x=x0);
_EnvAllSolutions := false:
_EnvExplicit := true:
sol_C:=_C2=solve(eq,_C2);
sol:=eval(sol,sol_C);
odetest(%,[ode,IC])

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

y(0) = 0

0

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

0 = -(-1+exp(RootOf(-Intat(-(1/2)/(tau*(-1+exp(tau))^(1/2)*exp(-tau)), tau = _Z)+_C2)))^(1/2)

_C2 = Intat(-(1/2)*exp(tau)/(tau*(-1+exp(tau))^(1/2)), tau = 0)

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

[RootOf(Intat(exp(tau)/(tau*(-1+exp(tau))^(1/2)), tau = _Z)+2*x-Intat(exp(tau)/(tau*(-1+exp(tau))^(1/2)), tau = 0))-ln(exp(RootOf(Intat(exp(tau)/(tau*(-1+exp(tau))^(1/2)), tau = _Z)+2*x-Intat(exp(tau)/(tau*(-1+exp(tau))^(1/2)), tau = 0)))), 0]

 

 

 

 

Download odetest_fail_when_using_envAllsol_maple_2025_1_oct_21_2025.mw

The nice addition added to Maple 2022 in this  post made it clear that c__1 and _C1 are the same under the cover.

But then why in Maple 2025.1 it does not give this?

I found this when I was trying to find constants of integrations in solution of an ode, and used 

                 indets(sol,And(symbol, suffixed(_C, nonnegint))); 

Which did not find the constants of integration, since I happened to have typed the solution using c__1 and not _C1, but I thought they are the same.

Did something change or I still dont understand well the difference between c__1 and _C1 ?

Worksheet below.

interface(version);

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

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.`

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.`

restart;

sol:= y(x)=-cos(x)/2+sin(x)/2+c__1*exp(-x);
indets(sol,And(symbol, suffixed(_C, nonnegint)));

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

{}

sol:= y(x)=-cos(x)/2+sin(x)/2+c__1*exp(-x);
indets(sol,And(symbol, suffixed(c__, nonnegint)));

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

{c__1}

sol:= y(x)=-cos(x)/2+sin(x)/2+_C1*exp(-x);
indets(sol,And(symbol, suffixed(c__, nonnegint)));

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

{}

sol:= y(x)=-cos(x)/2+sin(x)/2+_C1*exp(-x);
indets(sol,And(symbol, suffixed(_C, nonnegint)));

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

{_C1}

c__1 - _C1

c__1-_C1

addressof(c__1);

36893628553737883996

addressof(_C1);

36893628553623934140

Download why_c1_and_C1_not_same_oct_19_2025.mw

Update

Found out why. This only works if one calls dsolve() first.  Here is an example

sol:=dsolve(diff(y(x),x)=x)

y(x) = (1/2)*x^2+c__1

c__1 - _C1;

0

indets(sol,And(symbol, suffixed(_C, nonnegint)));

{c__1}

restart;

my_sol:=y(x)=(x^2)/2+c__1;

y(x) = (1/2)*x^2+c__1

c__1 - _C1;

c__1-_C1

indets(my_sol,And(symbol, suffixed(_C, nonnegint)));

{}

 

 

Download why_c1_and_C1_not_same_oct_19_2025_V1.mw

But this is really confusing. c__1 before calling dsolve is not the same as c__1 after calling dsolve.

It will be better if Maple is changed such that these work the same all the time without having to call dsolve() first.

Maple help does not have an example I could find showing the right way to call method, which is meant to be called only from the constructor the object, before the object is fully build.

Help page does not have such example.

This worksheet shows 3 possible ways to do this. All seem to work fine. I am sure one can come up with more variations.

The question is, which one of these calls is the "right" way?

The method called from the constructor in this example is called process_age().

If someone knows an official Maple documentation showing one example of calling  a proc from constructor that will also help.

Version 1

 

restart;

module person()
   option object;

   local _name::string;
   local _age::posint;

   export ModuleCopy::static := proc( _self, proto::person,
        name::string,age::posint,$)
        _name:=name;
        _age:=process_age(age);
   end proc;

   local process_age:=proc(age::posint,$)::posint;
         age+1;
   end proc;

   export get_age::static:=proc(_self,$)::posint;
          _age;
   end proc;
end module;

module person () local _name::string, _age::posint, process_age; option object; end module

o:=Object(person,"me",99);
o:-get_age()

module person () local _name::string, _age::posint, process_age; option object; end module

100

 

 

Version 2

 

restart;

module person()
   option object;

   local _name::string;
   local _age::posint;

   export ModuleCopy::static := proc( _self, proto::person,
        name::string,age::posint,$)
        _name:=name;
        _age:=process_age(age);
   end proc;

   local process_age::static:=proc(age::posint,$)::posint;
         age+1;
   end proc;

   export get_age::static:=proc(_self,$)::posint;
          _age;
   end proc;
end module;

module person () local _name::string, _age::posint; option object; end module

 

o:=Object(person,"me",99);
o:-get_age()

module person () local _name::string, _age::posint; option object; end module

100

 

 

Version 3

 

restart;

module person()
   option object;

   local _name::string;
   local _age::posint;

   export ModuleCopy::static := proc( _self, proto::person,
        name::string,age::posint,$)
        _name:=name;
        _age:=_self:-process_age(age);
   end proc;

   local process_age::static:=proc(_self,age::posint,$)::posint;
         age+1;
   end proc;

   export get_age::static:=proc(_self,$)::posint;
          _age;
   end proc;
end module;

module person () local _name::string, _age::posint; option object; end module

 

 

o:=Object(person,"me",99);
o:-get_age()

module person () local _name::string, _age::posint; option object; end module

100

 

 

Download correct_way_to_call_method_from_constructor_oct_17_2025.mw

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