nm

11353 Reputation

20 Badges

13 years, 8 days

MaplePrimes Activity


These are questions asked by nm

This below shows strange side effect of calling latex(sol,'output'='string'):

calling pdsolve on one pde, followed by latex() call, cause the next call after that to pdsolve to fail.

Any idea why this happens and any workaround so code can call latex in between without getting this error?

i.e.   sol:=pdsolve(...);  sol:=pdsolve(...);  WORKS

But    sol:=pdsolve(...); latex(sol,output=string);   sol:=pdsolve(...);  FAIL

Clearly there is some global/buffering issue somewhere. Why is calling latex makes pdsolve fail?

interface(version);

`Standard Worksheet Interface, Maple 2025.0, Linux, March 24 2025 Build ID 1909157`

Physics:-Version();

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

SupportTools:-Version();

`The Customer Support Updates version in the MapleCloud is 17 and is the same as the version installed in this computer, created May 5, 2025, 12:37 hours Eastern Time.`

restart;

pde :=  diff(u(x,t),t)=k*diff(u(x,t),x$2)+(exp(-c*t)*sin(2*Pi*x/L));
ic  :=  u(x,0)=f(x);
bc  :=  D[1](u)(0,t)=0, D[1](u)(L,t)=0;
sol:=pdsolve([pde,ic,bc],u(x,t)) assuming L>0,t>0,k>0:

diff(u(x, t), t) = k*(diff(diff(u(x, t), x), x))+exp(-c*t)*sin(2*Pi*x/L)

u(x, 0) = f(x)

(D[1](u))(0, t) = 0, (D[1](u))(L, t) = 0

the_latex:=latex(sol,'output'='string'): #THIS CAUSE ERROR in next command, if this was not here, next call works

pde := diff(u(x,t),t)=k*diff(u(x,t),x$2)-beta*u(x,t);
bc:= D[1](u)(0,t)=0,D[1](u)(Pi,t)=0;
ic  := u(x,0)=x;
sol:=pdsolve([pde,bc,ic],u(x,t)) assuming beta>0;

diff(u(x, t), t) = k*(diff(diff(u(x, t), x), x))-beta*u(x, t)

(D[1](u))(0, t) = 0, (D[1](u))(Pi, t) = 0

u(x, 0) = x

Error, (in assuming) when calling 'unknown'. Received: 'invalid input: diff received Pi, which is not valid for its 2nd argument'

 


 

Download strange_latex_effect.mw

 

This solution by dsolve is correct. I get same solution. The problem is odetest does not give zero.

All my simplification attempts failed and adding assumptions to call to odetest does not change anything for what I tried. i.e. could not make Maple show that the result of odetest is zero.

Any one can come up with smart way to verify this solution is correct? 

interface(version);

`Standard Worksheet Interface, Maple 2025.0, Linux, March 24 2025 Build ID 1909157`

restart;

ode:=diff(y(x),x)*(x-ln(diff(y(x),x))) = 1;
maple_sol:=dsolve(ode);

(diff(y(x), x))*(x-ln(diff(y(x), x))) = 1

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

the_residue:=odetest(maple_sol,ode);

(-x+ln(-1/LambertW(-1/exp(x)))-LambertW(-1/exp(x)))/LambertW(-1/exp(x))

Digits:=100;
plot(the_residue,x=0..10)

100

 

 

Download odetest_challange_may_15_2025.mw

Note that coulditbe(the_residue=0) gives true, but this is not reliable way to check, so this method does not coumt.

I wanted to try this simplification in Maple 2025, only to find timelimit hangs.

Waited 3 hrs when timelimit was 30 second. It seems simplify got locked up and timelimit does not work.

Not only that, Maple itself hangs and clicking on retsrat kernel or red small bottom at lower level corner in Maple 2025 has no effect at all.  

Only way is to kill all of Maple from command line.

Make sure to save all your work before trying.

There are two bugs here: First is that timelimit still hangs (even though Maplesoft claimed it is fixed almost 5 years ago)

https://www.mapleprimes.com/maplesoftblog/213986-Introducing-Maple-Learn-officially

You will also be pleased to know that Maple 2021 addresses the timelimit() issue that you mentioned.

The second issue is that one can not close the kernel from frontend. (well, this is because kernel hanged)

Note that closing Maple works using File->EXIT but this leaves the Maple kernel/mserver  running  in background!

So had to go kill that process from command line manually also.

So make sure to do this, else you will end up with many mserver processes running in background after maple is closed if you try this more than one time.

Any one knows why this happens for this example? Should not timelimit have finally been fixed in Maple 2025?

I have been complaining about timelimit not always working for ages. Have no idea why Maplesoft can't figure solution to this problem for good. 

timelimit is the most important command for me, as without it, my program will never work and will just keep hanging.

I spend 50% of my time finding worarounds around Maple bugs instead of what I should be doing which is write more code.

interface(version);

`Standard Worksheet Interface, Maple 2025.0, Linux, March 24 2025 Build ID 1909157`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1869. The version installed in this computer is 1866 created 2025, May 6, 10:52 hours Pacific Time, found in the directory /home/me/maple/toolbox/2025/Physics Updates/lib/`

SupportTools:-Version();

`The Customer Support Updates version in the MapleCloud is 17 and is the same as the version installed in this computer, created May 5, 2025, 12:37 hours Eastern Time.`

restart;

e:= -a*(-1/2*((1/2*x)^a)^4*(2^a)^4*_C8^4*a*x+1/2*((1/2*x)^a)^3*(2^a)^3*(((2^a)^2*((
1/2*x)^a)^2*_C8^2-a^2*b^2+b^2)^2/(2^a)^2/((1/2*x)^a)^2/_C8^2)^(1/2)*_C8^3*x+1/4
*((1/2*x)^a)^2*(2^a)^2*(((2^a)^2*((1/2*x)^a)^2*_C8^2-a^2*b^2+b^2)^2/(2^a)^2/((1
/2*x)^a)^2/_C8^2)^(1/2)*4^(1/2)*(x^2*(((1/2*x)^a)^4*(2^a)^4*_C8^4*a^2+(2^a)^4*(
(1/2*x)^a)^4*_C8^4+2*((1/2*x)^a)^2*(2^a)^2*_C8^2*a^4*b^2-2*((1/2*x)^a)^3*(2^a)^
3*(((2^a)^2*((1/2*x)^a)^2*_C8^2-a^2*b^2+b^2)^2/(2^a)^2/((1/2*x)^a)^2/_C8^2)^(1/
2)*_C8^3*a-4*a^2*b^2*(2^a)^2*((1/2*x)^a)^2*_C8^2+a^6*b^4-2*(1/2*x)^a*2^a*(((2^a
)^2*((1/2*x)^a)^2*_C8^2-a^2*b^2+b^2)^2/(2^a)^2/((1/2*x)^a)^2/_C8^2)^(1/2)*_C8*a
^3*b^2+2*b^2*(2^a)^2*((1/2*x)^a)^2*_C8^2-a^4*b^4+2*(1/2*x)^a*2^a*(((2^a)^2*((1/
2*x)^a)^2*_C8^2-a^2*b^2+b^2)^2/(2^a)^2/((1/2*x)^a)^2/_C8^2)^(1/2)*_C8*a*b^2-a^2
*b^4+b^4)/(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((2^a)^2*((1/2*x)^a)^2*_C8^2-a^2*b^2+b^2)^2/(2^a)^2/((1
/2*x)^a)^2/_C8^2)^(1/2)/((1/2*x)^a)^2/(2^a)^2:

try
  timelimit(30, (simplify(e) assuming real)):
catch:
   print("cought timelimit");
end try:

 

 

Download timelimit_hang_in_maple_2025.mw

is it possible to ask Maple to verify ode solution obtained from book, which is given in parametric form to check if it is correct?

I know odetest supports both explicit and implicit solutions. But parametric solution is neither of these.

The solution in parametric form makes it look simple to look at and understand, but at same time, not practical in terms of obtaining an explicit solution to verify it and to use it.

The book "handbook of exact solution for ordinary differential equations" by Polyanin and Zaitsev have many such solutions.

Here is one such example of many

I can not just give odetest the y(x) solution above, because the right side depends on tau, which is parameter. If I try to solve for tau in terms of x from the first equation it will become so complicated and odetest hangs. So a whole new different approach is needed as brute force method is not practical in most cases.

restart;

ode:=y(x)*diff(y(x),x)-y(x)=A*x+B;
book_sol:=y(x)=_C1*t*exp( - Int( t/(t^2-t-A),t));
eq:=x=_C1*exp(  - Int( t/(t^2-t-A),t))-B/A;

y(x)*(diff(y(x), x))-y(x) = A*x+B

y(x) = _C1*t*exp(-(Int(t/(t^2-A-t), t)))

x = _C1*exp(-(Int(t/(t^2-A-t), t)))-B/A

value(eq):
solve(%,t):
simplify(eval(book_sol,t=%));

y(x) = _C1*exp(-RootOf(4*A*exp(2*_Z)-4*cosh((ln((A*x+B)/(A*_C1))-_Z)*(4*A+1)^(1/2))^2+exp(2*_Z))+Intat(_a/(-_a^2+A+_a), _a = RootOf(-A*exp(2*RootOf(4*A*exp(2*_Z)-4*cosh((ln((A*x+B)/(A*_C1))-_Z)*(4*A+1)^(1/2))^2+exp(2*_Z)))+_Z^2-exp(RootOf(4*A*exp(2*_Z)-4*cosh((ln((A*x+B)/(A*_C1))-_Z)*(4*A+1)^(1/2))^2+exp(2*_Z)))*_Z+1)*exp(-RootOf(4*A*exp(2*_Z)-4*cosh((ln((A*x+B)/(A*_C1))-_Z)*(4*A+1)^(1/2))^2+exp(2*_Z)))))*RootOf(-A*exp(2*RootOf(4*A*exp(2*_Z)-4*cosh((ln((A*x+B)/(A*_C1))-_Z)*(4*A+1)^(1/2))^2+exp(2*_Z)))+_Z^2-exp(RootOf(4*A*exp(2*_Z)-4*cosh((ln((A*x+B)/(A*_C1))-_Z)*(4*A+1)^(1/2))^2+exp(2*_Z)))*_Z+1)

odetest(%,ode); #hangs

Download how_to_verify_parametric_solution_to_ode.mw

Some more examples from the book where solutions are given only in parametrric form

update

inspired by solution below by @acer, I found if I just use Solve on the x equation, in order to find t as function of x, and use that in the y equation, it will automatically return solution using RootOf.

Hence no need to explicitly evaluate the integral or explicity set up the RootOf manually.

Now odetest work. 

restart;

ode:=y(x)*diff(y(x),x)-y(x)=A*x+B;
book_sol:=y(x)=_C1*t*exp( - Int( t/(t^2-t-A),t));
eq:=x=_C1*exp(  - Int( t/(t^2-t-A),t))-B/A;

y(x)*(diff(y(x), x))-y(x) = A*x+B

y(x) = _C1*t*exp(-(Int(t/(t^2-A-t), t)))

x = _C1*exp(-(Int(t/(t^2-A-t), t)))-B/A

PDEtools:-Solve(eq,t);

t = RootOf(c__1*exp(Intat(_a/(-_a^2+A+_a), _a = _Z))*A-A*x-B)

simplify(eval(book_sol,%));

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

odetest(%,ode);

0

#compare to Maple's
simplify(dsolve(ode,useInt));

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

odetest(%,ode);

0

 

 

Download how_to_verify_parametric_solution_to_ode_V2.mw

Is there a trick to make Maple simplify 

to

I can't use the exp() trick given in earlier questions, since there is no exp here. Below are my attempts. Can someone find another smart trick to do this simplification? Should simplify() have simplified it as is with no assumptions or using tricks? This is all done in code, so solutions can not depend on "looking on screen" and deciding what to do for each step.

interface(version);

`Standard Worksheet Interface, Maple 2025.0, Linux, March 24 2025 Build ID 1909157`

restart;

interface(rtablesize=30);

[10, 10]

A:=-(sqrt(3)*sqrt(-2*C1 - 2*x) - 3)/(3*sqrt(-2*C1 - 2*x)*x);

-(1/3)*(3^(1/2)*(-2*C1-2*x)^(1/2)-3)/((-2*C1-2*x)^(1/2)*x)

B:=-(1/(sqrt(3)*x)) + 1/(sqrt(2)*x*sqrt(-x - C1));

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

simplify(A-B);

0

MmaTranslator:-Mma:-LeafCount(A);
MmaTranslator:-Mma:-LeafCount(B);

29

26

full_simplify:=proc(e::anything,assum::anything)
   local result::list;

   #add more methods as needed

   result:=[(simplify(e) assuming assum),
            (simplify(e,size=false) assuming assum),
            (simplify(e,size) assuming assum),
            (simplify(e,sqrt) assuming assum),
            (simplify(combine(e)) assuming assum),
            (simplify(combine(e),size) assuming assum),
            (radnormal(evala( combine(e) )) assuming assum),
            (simplify(evala( combine(e) )) assuming assum),
            (evala(radnormal( combine(e) )) assuming assum),
            (simplify(radnormal( combine(e) )) assuming assum),
            (evala(factor(e)) assuming assum),
            (simplify(e,ln) assuming assum),
            (simplify(e,power) assuming assum),
            (simplify(e,RootOf) assuming assum),
            (simplify(e,sqrt) assuming assum),
            (simplify(e,trig) assuming assum),
            (simplify(convert(e,trig)) assuming assum),
            (simplify(convert(e,exp)) assuming assum),
            (combine(e) assuming assum)
   ];   
   RETURN( result )

end proc:

Vector(full_simplify(A,real))

Vector(19, {(1) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (2) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (3) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (4) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (5) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (6) = -(1/3)*(sqrt(-6*C1-6*x)-3)/(sqrt(-2*C1-2*x)*x), (7) = (1/6)*sqrt(-2*C1-2*x)*(sqrt(-6*C1-6*x)-3)/((C1+x)*x), (8) = (1/6)*sqrt(-2*C1-2*x)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/((C1+x)*x), (9) = (1/6)*sqrt(-2*C1-2*x)*(sqrt(-6*C1-6*x)-3)/((C1+x)*x), (10) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (11) = -(1/6)*(2*sqrt(3)*C1+2*sqrt(3)*x+3*sqrt(-2*C1-2*x))/((C1+x)*x), (12) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (13) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (14) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (15) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (16) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (17) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (18) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (19) = -(1/3)*(sqrt(-6*C1-6*x)-3)/(sqrt(-2*C1-2*x)*x)})

Vector(full_simplify(A,positive))

Vector(19, {(1) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (2) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (3) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (4) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (5) = (1/3)*(-sqrt(3)*sqrt(2*C1+2*x)-3*I)/(sqrt(2*C1+2*x)*x), (6) = -(1/3)*(I*sqrt(6*C1+6*x)-3)/(sqrt(-2*C1-2*x)*x), (7) = (1/6)*sqrt(-2*C1-2*x)*(I*sqrt(6*C1+6*x)-3)/((C1+x)*x), (8) = -(1/6)*sqrt(2*C1+2*x)*(sqrt(3)*sqrt(2*C1+2*x)+3*I)/((C1+x)*x), (9) = (1/6)*sqrt(-2*C1-2*x)*(I*sqrt(6*C1+6*x)-3)/((C1+x)*x), (10) = (1/3)*(-sqrt(3)*sqrt(2*C1+2*x)-3*I)/(sqrt(2*C1+2*x)*x), (11) = -(1/6)*(2*sqrt(3)*C1+2*sqrt(3)*x+3*sqrt(-2*C1-2*x))/((C1+x)*x), (12) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (13) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (14) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (15) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (16) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (17) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (18) = -(1/3)*(sqrt(3)*sqrt(-2*C1-2*x)-3)/(sqrt(-2*C1-2*x)*x), (19) = -(1/3)*(I*sqrt(6*C1+6*x)-3)/(sqrt(-2*C1-2*x)*x)})

 

 

Download simplification_may_8_2025.mw

For reference, using another software

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