## Travelling wave reduction of a PDE...

Dear Maple Community,

I would like to ask you a question which will certainly be elementary for you. Imagine that I have a PDE (or, more generally, a system of PDEs) with (t, x) being independent variables, and the dependent variable defining the wave height or the fluid particle velocity u(t,x). The best example is the famous KdV equation:

u[t] + u*u[x] + u[x,x,x] = 0.

Now, I would like to automatically derive the ODE(s) that satisfy the travelling waves of this equation. Namely, we have to substitute the travelling wave ansatz u(t,x) = U(X) = U(x - c*t), where c is the travelling wave speed. In the case of the KdV equation, we obtain the following ODE:

-c*U' + U*U' + U''' = 0,

where prime ' denotes the derivative with respect to the new variable X.

My question is the following: What is the best way to automatically obtain this PDE -> ODE reduction in Maple?

Kind regards,

DDe

## simplifying a/sqrt(tan(x+c__1)^2+1);...

How to make Maple simplify a/sqrt(tan(x+c__1)^2+1); to a/sqrt(sec(x+c__1)^2);  ?

Below is worksheet. since the second one is smaller in leaf size, expected simplify(...,size) to do it, But it did not. Any suggestions?

 > LC:=MmaTranslator:-Mma:-LeafCount; e1:=a/sqrt(tan(x+c__1)^2+1); e2:=a/sqrt(sec(x+c__1)^2);

 > LC(e1);

 > LC(e2);

 > #we see they are same simplify(e1-e2);

 > #both nothing below make e1 to e2 simplify(e1); #not good simplification at all. Adds csgn. LC(%);

 > #expected this to do it but no simplify(e1,size); LC(%);

 > simplify(e1,trig);

 > combine(e1,trig);

 >

Using some other software:

## Where is the code that simplifies this ...

Can't figure out what code makes this simplification.
If this simplification works, it will be a part of a larger simplication procedure ( if it not conflicts hopefully)
vereenvouding_hoe_-vraag_MPF.mw

## PDEtools:-Solve vs. solve. RootOf form difference...

I was trying to find out why my solution was not validating for this ode. It turned out because I was using solve instead of PDEtools:-Solve. It took me sometime to find this.

This made huge difference on odetest to verify the solution.

This is very simple ode. We just need to integrate once. But first we have to solve for y'(x).

And here comes the difference. When I used solve to solve for y'(x), odetest did not verify the solution.

When using PDEtools:-Solve, it did.

The difference is how each returned the solution for y'(x). Both have RootOf but written differently and this made the difference.

1) Why solutions are written differently?

2) Is this to be expected? I have thought Solve uses same engine as solve below the cover.

3) is it possible to make solve give the same form as Solve or change to that form?

I am now changing more of my code to use PDEtools:-Solve because of this.

 > interface(version);

 > Physics:-Version();

Using solve

 > restart;

 > ode:=x-ln(diff(y(x),x))-sin(diff(y(x),x))=0; RHS:=solve(ode,diff(y(x),x));

 > mysol:= y(x) = Int(RHS,x)+c__1;

 > odetest(mysol,ode);

using PDEtools:-Solve (now it verifies) with no extra effort

 > restart;

 > ode:=x-ln(diff(y(x),x))-sin(diff(y(x),x))=0; RHS:=PDEtools:-Solve(ode,diff(y(x),x)): RHS:=rhs(%);

 > mysol:= y(x) = Int(RHS,x)+c__1;

 > odetest(mysol,ode);

Update

Here is a counter example. Where now it is the other way around.

Using solve makes odetest happy, but when using PDEtools:-Solve odetest does not verify the solution.  Same exact ODE.

 > interface(version);

 > Physics:-Version()

Example, using solve works

 > ode:=exp(diff(y(x), x) - y(x)) - diff(y(x), x)^2 + 1 = 0; RHS:=solve(ode,diff(y(x),x)); RHS:=eval(RHS,y(x)=y); mysol:=Intat(eval(1/RHS,y=_a),_a=y(x))=x+c__1; odetest(mysol,ode);

Example, using PDEtools:-Solve fails

 > ode:=exp(diff(y(x), x) - y(x)) - diff(y(x), x)^2 + 1 = 0; RHS:=rhs(PDEtools:-Solve(ode,diff(y(x),x))); RHS:=eval(RHS,y(x)=y); mysol:=Intat(eval(1/RHS,y=_a),_a=y(x))=x+c__1; odetest(mysol,ode);

 >

So now I have no idea which to use. Sometimes solve works and sometimes Solve works. I  guess I have to now solve the ode both ways each time and see which works.

## My rant of the day...

This is an extremely common situation; either some moderator displaced or deleted the question, or the OP deleted himself (herself).
Whatever the reason, it's always extremely upsetting to be confronted with this situation, which shows how rude, to put it mildly, some people can be.

Initial question (this day, about 2 hours ago)

Comment

## why print shows nothing when Matrix is empty?...

Should not  print("my matrix is ",A) at least print "my matrix is " even if A is not correctly filled/setup?

Notice that nothing shows on screen when using print (but lprint does)

Is this expected? If it makes any difference, I am using worksheet and this is my display options

 > interface(version);

 > A:=Matrix(1,0);
 > print("My matrix is =",A);
 > lprint("My matrix is =",A);

"My matrix is =", Matrix(1,0,{},datatype = anything,storage = rectangular,order
= Fortran_order,shape = [])

## Result of odetest changes depending on previous c...

If I do    odetest(...,odeA) I get correct result. But if I do    odetest(...,odeB);  odetest(...,odeA);   now it gives wrong output for the odeA one.

Same exact code. It just depends on the call done before it.

Why would issuing a command before changes the output of odetest? It seems Maple remembers something from last call. But I have no idea how to fix this.

Is there a way to tell odetest not to remember or cache any results from last calls? i.e. Can I clear its remember table before calling odetest??

This is messing all my testing now since I get different result each time depending on which call was made before. I can't do restart before testing each ode, since this is done in a loop.  I just need a way to tell Maple to clear its internal cache so that each call to odetest is not affected by last call result.

Doing forget(odetest); before the call had no effect.

Reported to Maplesoft.

Worksheet below

 > interface(version);

 > restart;

 > #EXAMPLE 1 ode:=x*diff(y(x),x)^n=0; sol:=dsolve(ode); odetest(sol,ode);

 > restart;

 > ode:=diff(y(x),x)^n=0; sol:=dsolve(ode); odetest(sol,ode);

 > ##EXAMPLE 1 repeated. Why now different result?? ode:=x*diff(y(x),x)^n=0; sol:=dsolve(ode); odetest(sol,ode);

Update

FYI, I got email from Maplesupport that Maple R&D group will look at this issue.

So hopefully this will be fixed in a future version of Maple.

I am not able to find a workaround but doing tracing I see that odetest does rememebr something from last call but have no idea to fix this myself.

## How to display an expression as I typed it?...

I want to display W__LJ as I typed it, without Maple running the calculations resulting in the output here below:

 > restart;
 > 'W__LJ = 0.75 + 0.98*((1.18/Gamma)^1.9 - (1.15/Gamma)^0.98)';
 (1)

This is important as I will place such expression in a plot like this:
textplot([2,0.9,typeset('W__LJ=0.75+0.98((1.18/Gamma)^1.9-(1.15/Gamma)^0.98)')],'font'=["helvetica","roman",35])
and I need it in the original functional form, which is easier to interpret.

## why this patmatch fails inside proc but works outs...

I can't figure this out. Same exact patmatch works in global worksheet. But fails inside a proc.

I am using same exact code. In proc, I am doing    a::anything where `a` is now local symbol ofcourse. In worksheet, it is global ofcourse. I make sure I clear `a` in worksheet each time also.

So why it pathmatch fail in the proc? I must be doing something wrong but do not see it.,

 > interface(version);

 > restart;

 > a:='a': stat:=0^n:
 > if patmatch(stat,0^a::anything) then      0;   else      stat;   fi;

 > foo:=proc(stat)   local a;   if patmatch(stat,0^a::anything) then      0;   else      stat;   fi; end proc:
 > #why this does not return zero as expected? foo(stat)

 >

Here is screen shot in debugger showing patmatch failed inside the proc

Very strange. What do I need to change in the proc to make it work as in worksheet?

## strange odetest result. Is this valid?...

Is the following valid result from odetest? is returns 0^n when 0 was expected.

Is this a bug or valid result? Maple solution is correct, so I expected 0 only not 0^n as result.

 > interface(version);

 > Physics:-Version();

 > ode:=diff(y(x), x)^n = 0

 > sol:=dsolve(ode)

 > odetest(sol,ode)

 > odetest(sol,ode) assuming n::real

 > odetest(sol,ode) assuming n>0

Update

Until this bug is fixed, I added the following to my code which checks for odetest result. it looks for 0^anything and changes it to 0.

```ode:=diff(y(x), x)^n= 0;
sol:=dsolve(ode);
stat:=odetest(sol,ode);
if patmatch(stat,0^a::anything) then 0; else stat; fi
```

gives    0

I found this problem when using odetest to check mysolution for this ode and was not getting 0 as expected,.

## simplification challenge. Exponentials in express...

These two expressions are the same

```e1:=-sqrt(-(exp(-2 + 2*x) - 2)*exp(-2 + 2*x))/(exp(-2 + 2*x) - 2);
e2:=1/sqrt(2*exp(-2*x)*exp(2) - 1);```

Is there an automated way to simplify e1 to e2? Below are my attempts. The closest I got is

`simplify(e1) assuming real;`

But that still does not give same as e2. I can do it by "hand" as shown. But I like to find automated way since this is done in code without looking at expression. So I can't use the "hand" method there.

We can assume everything in real domain.

 > interface(version);

 > e1:=-sqrt(-(exp(-2 + 2*x) - 2)*exp(-2 + 2*x))/(exp(-2 + 2*x) - 2); e2:=1/sqrt(2*exp(-2*x)*exp(2) - 1); plot([e1,e2],x=-3..3)

 > simplify(e1,size); simplify(e1,symbolic); simplify(e1) assuming real; #closest but still no cigar

 > #can do it "by hand" by dividing upstairs and downstrais by numerator A:=exp(-1 + x); B:=-exp(-2 + 2*x) + 2; e3:=1/sqrt( simplify(expand(B/A^2)))

 > #verify plot([e3,e2],x=-3..3)

## For which x- and y- values these two bounded 3D su...

I have two surfaces crossing the z=0 plane for some ranges of x and y values.

For the first surface, x=Gamma is bounded between 0 and 10 and y=rho between -1 and +1. For the second surface, x=Gamma_1 is bounded between 0 and 10 and y=Gamma_2 between 0 and 10 as well. I want to clearly identify (parametric):

1. For which Gamma and rho ranges of values the first surface is positive (and for which negative)
2. For which Gamma_1 and Gamma_2 ranges of values the second surface is positive (and for which negative)

Worksheet: sign_regions.mw (highlighted in yellow my two failed attempts)

## Selecl Remove from a set...

How do I get the susset that contains unknowns on the rhs of the elements?

 > restart
 >
 > # I need this subset {a=1/sqrt(2+A), b=6*sqrt(4+N),  d=5*H}
 >
 > C:={a=1/sqrt(2+A),b=6*sqrt(4+N) ,c=sqrt(7),d=5*H,,e=-12,f=-96}
 (1)
 > selectremove(has,indets(rhs~(C)),C)
 (2)
 > selectremove(has,lhs~(C)=indets(rhs~(C)),C)
 (3)

## How can I get the value of a slider component ?...

Hello, in a Maple script intended for Maple Learn I need to use a slider but I don't know how to get its value.

What should I do to get it?