nm

11533 Reputation

20 Badges

13 years, 109 days

MaplePrimes Activity


These are questions asked by nm

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

I asked similar question 5 years ago about Physics update but it was not possible to find this information

How-To-Find-What-Changed-In-Physics

I'd like to ask now again same about  SupportTools. Can one find out what update is actually included in new version?

Even if it is just 2-3 lines. It will be good if users had an idea what was fixed or improved in the new version.

Any update to software should inlcude such information. Not asking for details, just general information will be nice. Right now one does an update and have no idea at all what the new update fixed or improved which is not good.

May be such information can be displayed on screen after a user updates?

according to what is new in Maple 2025, it says

  • Maple 2025 introduces several important improvements to simplify regarding expressions containing exponential, trigonometric, hyperbolic, and/or inverse trigonometric functions, resulting in more compact results. Other commands in the math library also provide simpler results due to these improvements.

But I still see weakness in simplify. (see also recent question).

Here is an example, A and B below are equivalent mathematically. But A is almost twice as big. So one would expect simplify(A) to return B. right? But it does not. Also using size option has no effect.  

Does one need more tricks in Maple to make it simplify this? Is this not something that a powerful CAS software like Maple should have been able to do?

interface(version);

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


A:=(-8*x - 16)*exp(x/2) + x^2 + 4*x + 16*exp(x) + 4;
B:=(4*exp(x/2)-x-2)^2;

(-8*x-16)*exp((1/2)*x)+x^2+4*x+16*exp(x)+4

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

#check leaf size
MmaTranslator:-Mma:-LeafCount(A);

22

MmaTranslator:-Mma:-LeafCount(B);

13

#check they are the same
simplify(A-B);

0

#then why Maple can not simplify A to B ??
simplify(A);
simplify(A,size);
simplify(A,size,exp);
simplify(A) assuming real;

(-8*x-16)*exp((1/2)*x)+x^2+4*x+16*exp(x)+4

(-8*x-16)*exp((1/2)*x)+x^2+4*x+16*exp(x)+4

(-8*x-16)*exp((1/2)*x)+x^2+4*x+16*exp(x)+4

(-8*x-16)*exp((1/2)*x)+x^2+4*x+16*exp(x)+4

Student:-Precalculus:-CompleteSquare(A)

(-8*x-16)*exp((1/2)*x)+x^2+4*x+16*exp(x)+4

 

 

Download why_can_not_simplify_may_4_2025.mw

Using another software, all what is needed is call to Simpify to do it:

I also tried my most power full_simplify() function in Maple, and it had no effect

full_simplify:=proc(e::anything)
   local result::list;
   local f:=proc(a,b)
      RETURN(MmaTranslator:-Mma:-LeafCount(a)<MmaTranslator:-Mma:-LeafCount(b))
   end proc;

   #add more methods as needed

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

end proc:

Calling full_simplify(A) did not simplify it.

I wanted to search for all files with some extention in directory tree. But when adding depth=infinity and also adding 'select'="*.log" (or whatever the extension I want is), then it returns an empty list even though there are files with this extension but deep in the tree.

If I remove select, then it does work, but it returns list of the files in the tree. Which I do not want. I want to filter these by select.

If I remove depth=infinity then select works but only finds such files at top level of the directory and does look down the tree where there are more such files.

It seems select and depth conflict with each others.  Adding 'all' option makes no difference.

I do not remember now if I reported this before or not.

Here is worksheet showing this problem

interface(version);

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

folder_name:="/home/me/maple2025"; #fails to find all such files
FileTools:-ListDirectory(folder_name,'select'="*.wav",depth=infinity);

"/home/me/maple2025"

[]

folder_name:="/home/me/maple2025"; #works but only top level
FileTools:-ListDirectory(folder_name,'select'="*.log");

"/home/me/maple2025"

["Maple_2025_Install_2025_04_03_12_34_10.log"]

folder_name:="/home/me/maple2025"; #works but this finds everything
FileTools:-ListDirectory(folder_name,depth=infinity);

"/home/me/maple2025"

`[Length of output exceeds limit of 10000]`

 


 

Download listdirectory_may_3_2025.mw

How can one get list of files with specific extension in the whole tree? And why is adding select makes it not work? Help does not say anything about select does not work when adding depth=infinity.

I suppose I can get list of all files in tree, then iterate over the list and remove all entries that do not end with the extension I wanted. But this is what select is supposed to do. For example

folder_name:="/home/me/maple2025/"; #works but this finds everything
L:=FileTools:-ListDirectory(folder_name,depth=infinity):
map(X->`if`(FileTools:-Extension(X)="wav",X,NULL),L);

Gives list of only files with extension "wav". So the above is workaround for now.

First 7 8 9 10 11 12 13 Last Page 9 of 204