Maple 2020 Questions and Posts

These are Posts and Questions associated with the product, Maple 2020

Let's say you make a tabulate of plots (using tabulate, because you don't want equal space for your plots as in array-plot etc). Then how should one save or export the final result as one eps or pdf file? When I right click and choose export, it only save one cell of the tabulate alone.

When translating initial conditions, for derivatives, to Latex, the output is not easy to read, and was wondering how to make it more standard.

For example, let say initial conditions for second order ODE are [y(0)=0,D(y)(0)=3] in Maple syntax.  I convert these to Latex using

restart;
ic:=[y(0)=0,D(y)(0)=3];
Physics:-Latex(ic)

which gives

               [y \left(0\right) = 0, D\left(y \right)\left(0\right) = 3]

The problem is with derivatives. They are hard to read, unless someone knows Maple. The above renders are

I'd like to get the above to standard form 

Which more easily understood and is the standard in textbooks and papers.

This issue does not show up in Mathematica, because in Mathematica initial conditions can be entered as  {y[0]==0,y'[0]==3} and this translates directly as is

Which renders a

I know in Maple document mode, 2D math input, one can also enter the IC the same as with Mathematica, which is easier, but the Latex translation still the same as with the worksheet 1-D math.

Going back to Maple, I could enter the initial conditions instead as follows

restart;
ic:=[y(0)=0,eval(diff(y(x),x)=3,x=0)];
Physics:-Latex(ic)

And now the latex generated renders as

Which might be more understandble but too heavy weight compared to the simpler form y'(0)=3 and I remember reading that use eval() as above is not as safe as using the D(y)()... notation for initial conditions.

Are there any other tricks that would allow the latex of derivative to show in the standard form to make it easier to read?

Is it possible for Physics:-Latex to automatically detect the form D(y)(x0)=y0 and generate y'(x0)=y0 for its Latex? This will be the ideal solution. This will apply to higher derivatives as well. For example 

Physics:-Latex( (D@@2)(y)(0)=3)

Now gives

         D^{\left(2\right)}\left(y \right)\left(0\right) = 3

which renders as

While a much better output would be the standard

This will go a long way towards improving the Latex generated by Maple.

Any suggestions?

 

 

Hello again,

I want to maximize a function u(k,x) with the following form

u := (k, x) -> (1 - theta(sP, sL))((p + sP)*q(x) - w(k)*x + sL) + theta(sP, sL)*b(k)

where theta, q, b, w have previously being defined and (sP,sL) are parameters. I want to maximize u and therefore,

with(Optimization):
Maximize(u(k, x), variables = {k, x}, k = 0 .. 1);

My question is how to tell Maple that I want my optimal solution, (k*,x*) to be expressed as a function of (sP,sL)?

 

Please answer the questions posed in the body of the uploaded worksheet.

The worksheet employs the command DirectSearch[SolveEquations]. Responders must establish their own connection to the DirectSearch package.

Invert_Torus.mw

When i enter  Physics:-Version() I see the output

The "Physics Updates" version "859" is installed but is not active. The active version of Physics is within the library

   C:\Program Files\Maple 2020\lib\maple.mla, created 2020,  March 4, 20:36 hours

 

I tried to install it using Maple Cloud. The installation is stuck as seen below. Also i deleted the text file in the toolbox 2020 folder, maybe in the hope of starting from scratch.
 

Can someone please explain what to do to manually add the physics update, step by step. I am not that computer savvy as some of the users appear in other posts , I did try reading some.
I tried to download the physics update manually but I keep ending up with the same maple worksheet that says you need to use maplecloud.


In case you cannot read the text in the image

I notice that when I enter ?convert or ?convertininto the maple prompt, the help window opens once and then ceases to function.

Update. It seems that the problem is not restricted to a specific command, this occurs for any command. To replicate, open help using F1, exit maple help, then open help again using F1. Maple help won't open again. I have to do a hard exit to get it to work again.

Platform details:

I am trying to apply assumptions to the solution set of an equation. I've tried assume and assuming (see attached) to no avail. What am I missing? How can I achieve this?assume.mw
 

`assuming`([solve(x^2-x-2 = 0, x)], [x > 0])

2, -1

(1)

assume(x > 0)

solve(x^2-x-2 = 0, x)

2, -1

(2)

``


 

Download assume.mw

 

I am generating splines using CurveFitting[Spline] command, which produces piecewise functions. I would like to extract the different "pieces" of the spline for use elsewhere. How do I do that? In the attached worksheet, for example, I would like to extract (59*x^2)/756, -1/84*x^2 + 17/63*x - 17/84, and -19/504*x^2 + 19/36*x - 61/72. There has to be a way to do this, but I'm coming up short.

spline.mw
 

with(CurveFitting)

f := Spline([[0, 0], [3, 1/2], [7, 1]], x, degree = 2)

piecewise(x < 3/2, (59/756)*x^2, x < 5, -(1/84)*x^2+(17/63)*x-17/84, -(19/504)*x^2+(19/36)*x-61/72)

(1)

``


 

Download spline.mw

 

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

Hello

I am trying to use Threads in my procedures as much as possible.  However, one of them returned different results when compared to map or Grid:-Map (I have checked if the used functions are threadsafe (perhaps I miss something)).  Here is the procedure (optimization of the code is most welcome).

searchMonomialsEqns:=proc(conds::set,Eqns::list,Vars::list,poolofeqns::list(list))
description "Find if a set of monomials in an equation can be found in a pool of monomials and returns the condition when it is true":
local A:=Array(1..0),
      C,
      i,
      res,
      n:=numelems(Eqns):
#  Find the monomials of Eqns
res:=subs(conds,Eqns):
for i from 1 to n do
    C:= coeffs(expand(lhs(res[i])-rhs(res[i])),Vars, 'M'):
    A,={M}:
end do:
ifelse(member([seq(A)],poolofeqns)=false,NULL,conds):
end proc:

1) Threads:-Map

ans1:=CodeTools:-Usage(Threads:-Map(w->searchMonomialsEqns(w,eqns[1..2],vars[2..3],validYZeqnMon),conds5)):nops(ans1);

returns

memory used=0.58GiB, alloc change=139.56MiB, cpu time=40.23s, real time=11.12s, gc time=1.01s

                              8613

 

2) map

ans2:=CodeTools:-Usage(map(w->searchMonomialsEqns(w,eqns[1..2],vars[2..3],validYZeqnMon),conds5)):nops(ans2);

returns

memory used=0.57GiB, alloc change=-4.00MiB, cpu time=22.48s, real time=21.55s, gc time=1.70s

                              8637

3) Grid:-Map

ans3:=CodeTools:-Usage(Grid:-Map(w->searchMonomialsEqns(w,eqns[1..2],vars[2..3],validYZeqnMon),conds5)):nops(ans3);

return

memory used=23.29MiB, alloc change=21.88MiB, cpu time=3.77s, real time=2.25s, gc time=3.14s

                              8637

Although the number of elements is the same, Grid:-Map returns the result with set function mentioned in my previous post. (I am aware that CodeTools:-Usage is pointless here).

4) Threads:-Seq

ans4:=CodeTools:-Usage([Threads:-Seq](searchMonomialsEqns(conds5[i],eqns[1..2],vars[2..3],validYZeqnMon),i=1..nops(conds5))):nops(ans4);

returns

memory used=0.58GiB, alloc change=0 bytes, cpu time=33.99s, real time=8.68s, gc time=644.74ms

                              8622

What am I missing?   

Many thanks

Ed

 

"What's new in Maple 2020" explain an exciting new option for DrawGraph: layout=interactive, that should allow you to move vertices in the plot. I tried this in the help page opened in a worksheet window and it works.

Unfortunately when I write in a new worksheet the command

with(GraphTheory): with(RandomGraph): G:=RandomGraph(10,25); DrawGraph(G,layout=interactive)

I get the error

"Error, invalid input: GraphTheory:-DrawGraph expects value for keyword parameter [style, layout] to be of type identical(none, bipartite, circle, default, fixed, grid, interactive, network, spectral, spring, spring[constant], tree, user, planar, random), but received plots:-interactive"

Could you help me? Thanks

This is really a math question. But I can't figure how Maple did it.

Maple solves the ODE with 2 initial conditions correctly.

But if I use the general solution, and setup the set 2 equations, and tell Maple to solve _C1 and _C2, it says there is no solutions. Which is correct.

I would really like to know how Maple then managed to solve for these initial conditions.  This is problem from text book

I know how to solve it by hand to obtain general solution. But do not know how find solution that satisfies the IC's. when pluggin the initial conditions, the resulting 2 equation have no solution.

restart;
ode:=2*diff(y(x),x$2)=exp(y(x));
maple_general_sol:=dsolve(ode);
odetest(maple_general_sol,ode);
IC:=y(0)=0,D(y)(0)=1;
maple_sol_with_IC:=dsolve([ode,IC]);
odetest(maple_sol_with_IC,[ode,IC]);

The goal is to now take the general solution found by Maple above, and manually solve for _C1 and _C2:

eq1:=0=subs(x=0,rhs(maple_general_sol));
the_derivative:= diff(rhs(maple_general_sol),x):
eq2:=1=subs(x=0,the_derivative);

Two equations, two unknown. But using solve or PDEtools:-Solve produce no solution.

sol1:=solve([eq1,eq2],[_C1,_C2]);
sol2:=PDEtools:-Solve([eq1,eq2],[_C1,_C2]);

Looking at equation (1) above, we see that it is the same as 

eq1:=1=(tan(_C2/(2*_C1))^2 + 1)/_C1^2;

Because 0=ln(Z) means Z=1. Using the above simpler equation now gives

eq1:=1=(tan(_C2/(2*_C1))^2 + 1)/_C1^2;
the_derivative:= diff(rhs(maple_general_sol),x):
eq2:=1=subs(x=0,the_derivative);
sol1:=solve([eq1,eq2],[_C1,_C2]);

We see that there is indeed no solution. Second equation above says _C1= tan(.). Let tan(.)=Z. Plugging this in first equation gives Z^2= (Z^1+1) which has no solution for Z since this says 0=1 

So direct appliction of the initial conditions produces no solution. So how did Maple find the solution it obtained? I also tried using limits. But no luck. Book does not show how to obtain solution either. 

Any ideas?

 

When solving this by hand   sqrt(y)=tanh(x), I would square both sides to obtain  y=tanh(x)^2 as solution.  

Maple does this when RHS is tan,cos,sin, but not when RHS is hyperbolic.

Why is that, and how to best tell Maple to give  the simple solution? Here is an example

restart;
eq:=sqrt(y)=tanh(x);
sol:=solve(eq,y);

Compare to Mathematica:

I can post-process Maple solution like this

restart;
eq:=sqrt(y)=tanh(x);
sol:=solve(eq,y);
sol:=convert(sol,trigh);
sol:=simplify(sol)

Which is tanh(x)^2.  

But this is all too much work, since this is done in a program, and I do not know what specific convert to use at the time to try.

My question is, why does not maple simply solves   sqrt(y) = f(x)  giving     y=f(x)^2?  it works for generic function

restart;
eq:=sqrt(y)=f(x);
sol:=solve(eq,y);

it works for non-hyper trig functions also

restart;
eq:=sqrt(y)=tan(x);
sol:=solve(eq,y);

Is there a trick to make it work for hyperbolic functions also automatically?

ps. for now, to avoid all these issues, I am doing this

restart;
the_rhs:=tanh(x);
eq:=sqrt(y)=f;
sol:=solve(eq,y);
sol:=subs(f=the_rhs,sol);

Since I know that the RHS contains no y before hand. The above bypasses any issues Maple has with hyper trig functions.

I am currently trying to solve the following ODE using numerical methods:

diff(U(x), x$2) + [(z+ I*y)2/k12 -k22 + ((z+I*y)/k3)*sech(x)^2U(x)

Where the complex value (in this case, omega, has been written as z+Iy). I believe dsolve has capabilities for solving this as an initial value problem with complex values and thus to solve this as a boundary value problem I aim to use fsolve to find a zero other a function which is the (IVP solution) - (the non-initial boundary). This has worked very well for the case where y=0 however does not work for values of y>0, and it seems the problem is with fsolve. Any advice on how to deal with this problem, perhaps alternatives to fsolve? 

When Maple converts a matrix or a vector to Latex it uses latex array, which  is fine, but what it does is insert an exatra \\ at the end of the last row, just before the \end{array} 

This causes problem for some software which reads the latex file. It causes the software to take this as empty row and inserts a blank row at the end.

Here is a small example

A:=Matrix([[1,2],[3,4]]);
Physics:-Latex(A);

              \left[\begin{array}{cc}1 & 2 \\3 & 4 \\\end{array}\right]

Notice the extra \\  just before the \end{array} In Latex, this tells latex compiler to insert newline basically.

When opening the latex file using external software, which reads Latex and converts it to GUI, it show this

And now I have to go edit the latex by hand removing the extra \\ (inside the editor I can do global search and replace)

A better outout from Maple's Latex command would be the following

\left[\begin{array}{cc}1 & 2 \\3 & 4 \end{array}\right]

Even though both are valid Latex, the above is better.  I was wondering how hard it is to do this change.

All what the conversion needs to do is just check if the row in the matrix (or Vector) is the last one, and omit the extra \\ at the end of the last row. That is all. 

I could ofcourse write code to try to parse this each time I call Latex and to remove \\ myself in the program, but it will be much easier if Maple automatically did this.

 

ps. if the Latex conversion source code could be made public, others could help make improvement to it for free, benefiting Maple and everyone using it. Maplesoft would still approve the changes before checkin, and retain the copy right of the source code ofcourse. 

 

Maple 2020.1

 

First 30 31 32 33 34 35 36 Last Page 32 of 55