MaplePrimes Questions

Hi,

I am exploring the boxplot, and I see that I do not have the option to integrate 2 lists: One for observations and one for frequencies. The BoxPlot command only accepts one list (List A in my example). Is there a way to create the BoxPlot using the 'Obs' and 'Eff' lists? Thank you for your insight

QBoxPlot.mw

As Maple is not equipped to handle numerical solutions of elliptic PDEs, can anyone help top solve PDEs by finite differences or any other numerical solver?

pde.mw

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?

Thanks a lot in advance!

Kind regards,

DDe

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?

24832

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

MmaTranslator:-Mma:-LeafCount

a/(tan(x+c__1)^2+1)^(1/2)

a/(sec(x+c__1)^2)^(1/2)

LC(e1);

12

LC(e2);

10

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

0

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

a*csgn(sec(x+c__1))*cos(x+c__1)

11

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

a/(tan(x+c__1)^2+1)^(1/2)

12

simplify(e1,trig);

a/(tan(x+c__1)^2+1)^(1/2)

combine(e1,trig);

a/(tan(x+c__1)^2+1)^(1/2)

 


Using some other software:

 

 

 

Download tan_sec_simplification_june_9_2024.mw

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

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.

27860

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1757. The version installed in this computer is 1756 created 2024, June 5, 19:39 hours Pacific Time, found in the directory C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib\`

Using solve

 

restart;

27860

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

x-ln(diff(y(x), x))-sin(diff(y(x), x)) = 0

RootOf(_Z-exp(-sin(_Z)+x))

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

y(x) = Int(RootOf(_Z-exp(-sin(_Z)+x)), x)+c__1

odetest(mysol,ode);

-ln(RootOf(_Z-exp(-sin(_Z)+x)))+x-sin(RootOf(_Z-exp(-sin(_Z)+x)))

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

 

restart;

27860

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

x-ln(diff(y(x), x))-sin(diff(y(x), x)) = 0

RootOf(-x+ln(_Z)+sin(_Z))

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

y(x) = Int(RootOf(-x+ln(_Z)+sin(_Z)), x)+c__1

odetest(mysol,ode);

0

 

 

Download PDEtools_Solve_vs_solve_june_8_2024.mw

 

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.   


 

28652

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version()

`The "Physics Updates" version in the MapleCloud is 1757 and is the same as the version installed in this computer, created 2024, June 6, 14:53 hours Pacific Time.`

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);

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

Warning, solutions may have been lost

RootOf(-exp(_Z-y(x))+_Z^2-1)

RootOf(-exp(_Z-y)+_Z^2-1)

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

0

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);

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

RootOf(_Z^2*exp(y(x))-exp(_Z)-exp(y(x)))

RootOf(_Z^2*exp(y)-exp(_Z)-exp(y))

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

exp(RootOf(_Z^2*exp(y(x))-exp(_Z)-exp(y(x)))-y(x))-RootOf(_Z^2*exp(y(x))-exp(_Z)-exp(y(x)))^2+1

 


 

Download PDEtools_Solve_vs_solve_june_9_2024.mw

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.

 

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

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

21836

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

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 = [])

 

 

Download why_print_empty_june_7_2024.mw

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);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

restart;

4556

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

x*(diff(y(x), x))^n = 0

y(x) = c__1

0

restart;

4556

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

(diff(y(x), x))^n = 0

y(x) = c__1

0^n

##EXAMPLE 1 repeated. Why now different result??

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

x*(diff(y(x), x))^n = 0

y(x) = c__1

x*0^n

Download why_different_result_from_odetest_june_6_2024.mw

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.

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)';

W__LJ = .75+1.342152577*(1/Gamma)^1.9-1.123854165*(1/Gamma)^.98

(1)
 

NULL

Download display_formula.mw

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.

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

26148

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

restart;

26148

a:='a':
stat:=0^n:

if patmatch(stat,0^a::anything) then
     0;
  else
     stat;
  fi;

0

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)

0^n

 


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? 

Download patmatch_in_proc.mw

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.

25748

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1756 and is the same as the version installed in this computer, created 2024, June 5, 19:39 hours Pacific Time.`

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

(diff(y(x), x))^n = 0

sol:=dsolve(ode)

y(x) = c__1

odetest(sol,ode)

0^n

odetest(sol,ode) assuming n::real

0^n

odetest(sol,ode) assuming n>0

0^n

 

 

Download strange_odetest_result_june_6_2024.mw

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

 

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.


 

15244

interface(version);

`Standard Worksheet Interface, Maple 2024.0, Windows 10, March 01 2024 Build ID 1794891`

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)

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

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

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

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

-I*exp(-1+x)/(exp(-2+2*x)-2)^(1/2)

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

#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)))

exp(-1+x)

-exp(-2+2*x)+2

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

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

 

 


Download simplification_june_6_2024.mw

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)

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}

{a = 1/(2+A)^(1/2), b = 6*(4+N)^(1/2), c = 7^(1/2), d = 5*H, e = -12, f = -96}

(1)

selectremove(has,indets(rhs~(C)),C)

{}, {A, H, K, N, 1/(2+A)^(1/2), (4+N)^(1/2)}

(2)

selectremove(has,lhs~(C)=indets(rhs~(C)),C)

() = (), {a, b, c, d, e} = {H, K, N, (4+N)^(1/2)}

(3)
 

 

Download 2024-06-05_Q_Select_Remove_indet_elements.mw

First 9 10 11 12 13 14 15 Last Page 11 of 2338