Maple 2020 Questions and Posts

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

Hello

I need to detect if different expressions contain a radical. For example

aaa := X3*(alpha[2, 8]*(sqrt(X2/alpha[1, 7])*alpha[3, 8] + X1*alpha[3, 6])*X2 + X3*(alpha[2, 8] + alpha[3, 9]/2))/(X2*alpha[2, 8])

As can be noticed there is a square root in the expression.   

I have tried type(expr,sqrt) and has but to no avail. (I am not sure if I use them as they should though).   

Many thanks

 

Ed

 

Hi there.

As we all know if we multiply two polynomials f(x) and g(x) of degrees m and n respectively we get polynomial h(x)= f(x)*g(x) of degree m+n and with m+n+1 coefficients in general. Function modp1(('Multiply')(...)) doing this very well. But sometimes we don't need full resulting h(x) - just subset of monomials and subset of coefficients of h(x) - so we don't need to calculate all m+n+1 coefficients of h(x) and waste time and resources for that.

I would request some additional rework of modp1 package: by adding to modp1(('Multiply')(...)) two optional parameters - degrees of first and last calculating coefficients of h(x).

For example:

h:=modp1(Multiply(f, g,n-1,n+1), p) could calculate only monomials with n-1, n and n+1 degrees and set other monomials to zero.

Or maybe it should be new function:

h:=modp1(Multiply_Truncate(f, g,n-1,n+1), p)

 

Is it possible?

It would be great and very efficient in many tasks.

Thank you.

These are 4 equations in 4 unknowns. the equations are kinda long. But the issue is that PDEtools:-Solve hangs, while solve finishes instantly.

I have though before that  PDEtools:-Solve is a higher level API which ends up using solve? So why does it hang on this?

restart;

eqs:=[2 = c1+c2+c4-1, 0 = ((c2+c4-2)*(108+12*59^(1/2)*3^(1/2))^(1/3)+(1/12*c3*3^(1/2)+1/12*c2-1/6*c4)*(108+12*59^(1/2)*3^(1/2))^(2/3)+2*c3*3^(1/2)-2*c2+4*c4)/(108+12*59^(1/2)*3^(1/2))^(1/3), -1 = -1/6/(108+12*59^(1/2)*3^(1/2))^(2/3)*((((c2-2*c4)*3^(1/2)-3*c3)*59^(1/2)-33*c3*3^(1/2)+33*c2-66*c4)*(108+12*59^(1/2)*3^(1/2))^(1/3)+(2*c2+2*c4+12)*(108+12*59^(1/2)*3^(1/2))^(2/3)+((-12*c2+24*c4)*3^(1/2)-36*c3)*59^(1/2)-60*c3*3^(1/2)-60*c2+120*c4), -5 = ((((2*c2-4*c4)*3^(1/2)+6*c3)*59^(1/2)-30*c3*3^(1/2)-30*c2+60*c4)*(108+12*59^(1/2)*3^(1/2))^(1/3)+(((-c2+2*c4)*3^(1/2)+3*c3)*59^(1/2)+13*c3*3^(1/2)-13*c2+26*c4)*(108+12*59^(1/2)*3^(1/2))^(2/3)-96*(59^(1/2)*3^(1/2)+9)*(c2+c4))/(24*59^(1/2)*3^(1/2)+216)];

unknowns:=[c1, c2, c3, c4];

#han to put a timelimit, else it will never finish. I waited 20 minutes before.
timelimit(30,PDEtools:-Solve(eqs,unknowns));

#this completes right away
solve(eqs,unknowns);

 

Is this a known issue and to be expected sometimes?
 

restart;

interface(version);

`Standard Worksheet Interface, Maple 2020.1, Windows 10, July 30 2020 Build ID 1482634`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 851. The version installed in this computer is 847 created 2020, October 17, 17:3 hours Pacific Time, found in the directory C:\Users\me\maple\toolbox\2020\Physics Updates\lib\`

eqs:=[2 = c1+c2+c4-1, 0 = ((c2+c4-2)*(108+12*59^(1/2)*3^(1/2))^(1/3)+(1/12*c3*3^(1/2)+1/12*c2-1/6*c4)*(108+12*59^(1/2)*3^(1/2))^(2/3)+2*c3*3^(1/2)-2*c2+4*c4)/(108+12*59^(1/2)*3^(1/2))^(1/3), -1 = -1/6/(108+12*59^(1/2)*3^(1/2))^(2/3)*((((c2-2*c4)*3^(1/2)-3*c3)*59^(1/2)-33*c3*3^(1/2)+33*c2-66*c4)*(108+12*59^(1/2)*3^(1/2))^(1/3)+(2*c2+2*c4+12)*(108+12*59^(1/2)*3^(1/2))^(2/3)+((-12*c2+24*c4)*3^(1/2)-36*c3)*59^(1/2)-60*c3*3^(1/2)-60*c2+120*c4), -5 = ((((2*c2-4*c4)*3^(1/2)+6*c3)*59^(1/2)-30*c3*3^(1/2)-30*c2+60*c4)*(108+12*59^(1/2)*3^(1/2))^(1/3)+(((-c2+2*c4)*3^(1/2)+3*c3)*59^(1/2)+13*c3*3^(1/2)-13*c2+26*c4)*(108+12*59^(1/2)*3^(1/2))^(2/3)-96*(59^(1/2)*3^(1/2)+9)*(c2+c4))/(24*59^(1/2)*3^(1/2)+216)];
unknowns:=[c1, c2, c3, c4];

[2 = c1+c2+c4-1, 0 = ((c2+c4-2)*(108+12*59^(1/2)*3^(1/2))^(1/3)+((1/12)*c3*3^(1/2)+(1/12)*c2-(1/6)*c4)*(108+12*59^(1/2)*3^(1/2))^(2/3)+2*c3*3^(1/2)-2*c2+4*c4)/(108+12*59^(1/2)*3^(1/2))^(1/3), -1 = -(1/6)*((((c2-2*c4)*3^(1/2)-3*c3)*59^(1/2)-33*c3*3^(1/2)+33*c2-66*c4)*(108+12*59^(1/2)*3^(1/2))^(1/3)+(2*c2+2*c4+12)*(108+12*59^(1/2)*3^(1/2))^(2/3)+((-12*c2+24*c4)*3^(1/2)-36*c3)*59^(1/2)-60*c3*3^(1/2)-60*c2+120*c4)/(108+12*59^(1/2)*3^(1/2))^(2/3), -5 = ((((2*c2-4*c4)*3^(1/2)+6*c3)*59^(1/2)-30*c3*3^(1/2)-30*c2+60*c4)*(108+12*59^(1/2)*3^(1/2))^(1/3)+(((-c2+2*c4)*3^(1/2)+3*c3)*59^(1/2)+13*c3*3^(1/2)-13*c2+26*c4)*(108+12*59^(1/2)*3^(1/2))^(2/3)-96*(59^(1/2)*3^(1/2)+9)*(c2+c4))/(24*59^(1/2)*3^(1/2)+216)]

[c1, c2, c3, c4]

timelimit(30,PDEtools:-Solve(eqs,unknowns))

Error, (in expand/bigprod) time expired

solve(eqs,unknowns):

 


 

Download PDEtools_solve_issue_oct_23_2020.mw

What is the best way to handle this?  Many times one wants to return an expression from inside a proc, which uses local symbls, back to the user (global context).

The problem is, if one tries to simplify this returned expression, adding assumptions on some of the symbols in the expression, it does not work. Since the symbol used in the assuming is global, while the symbol inside the returned expression was local to the proc.

Even though the symbols look the same on the screen, they are actually different symbols, so the simplify does not work as expected.

Here is a simple example

restart;
foo:=proc()
local x;
  return exp(2*sqrt(1/x^2)*x*ln(x)) + exp(sqrt(1/x^2)*x*ln(x)) ;
end proc;

sol:=foo();

simplify(sol) assuming x>0

The above does not work. Since the "x" in assuming x>0 is global, while the "x" in the expression was local to the proc. So even though they look same, they are different symbols.

The standard way to handle this, is to pass the "x" to be used to build the solution, from the user to the proc(), so that when the expression is returned, the "x" used will be the global one. Like this

restart;
foo:=proc(x)
  return exp(2*sqrt(1/x^2)*x*ln(x)) + exp(sqrt(1/x^2)*x*ln(x)) ;
end proc;

sol:=foo(x);

simplify(sol) assuming x>0

Now it works:

But this method is not practical all the time. Suppose the local proc wants to generate an expression with other symbols in it, that the user does not know about. Say alpha, beta, z, eta, and so on. The user does not care about having to pass every possible symbol down on each call.  

Is there a way to tell assuming, that the symbols in assumptions command, are to be taken from the expression itself, and not to be global ones?    i.e. when doing 

simplify(sol) assuming x>0

I want Maple to take that "x" in assuming to be the "x" inside the expression only, and not a global "x".  

This will make life much simpler.  I remember seeing other use of assuming where this could be done, but I can't find it yet.

edit:

This is  just one example, where returning expression with new symbol from local proc can be required sometimes.

This is similar to using constant of integrations _C1 by dsolve when it returns a solution.

But those _C1 are all predefined as system/global symbols. But there can be cases where one needs to use new symbols. 

An example is where int() timesout or it does not produce result.

In this case, instead of leaving it as is (since I need to use the result and do not want Maple to keep evaluating it in the expression it is in), so  I replace int(integrand,x) with Int( new_integrand , alpha=0...x) where new_integrand is the same as integrand but with each in it, is replaced by new symbol alpha

This symbol alpha has to be local to the proc (it was not passed down by user). 

Maple uses _Z sometimes for such a cases, which I do not like. (it looks bad in Latex)

Here is an example

foo:=proc(x)
local int_result,alpha;
local integrand:=1/ln(x^2+1);

int_result:= int(integrand,x);
if has(int_result,'int') then  #did not integrate
   int_result:=Int(subs(x=alpha,integrand),alpha=0..x);
fi;

  return int_result;
end proc:

int_result:=foo(x)

The expression returned contains symbol alpha, which is local to the proc.  Only way around this, is to have the user pass in alpha as well as x, just in case it is needed, which is not practical to do.

This is just one example of many. Another example is when doing some transformation internally (change of variables) to convert the ode from one form to another, and I need to return those intermediate results back to caller. These substitutions use local symbols.

As I said, I could have used _Z or some other system/global known symbol for this. But I do not like how this looks in Latex. And if I need another symbol for another case, I have to look for another one.  Instead, I just make my own local symbols and use them in the expression. (Except for constant of integrations, I use those _C1,_C2, etc....

 

inequal({Re(ecs1) <= c, Re(ecs2) <= c, Re(ecs3) <= c}, Dm1 = 0 .. 1, c = 0 .. 1, color = "DodgerBlue", numpoints = 8000, transparency = 0, labels = [D[m1], c], axesfont = [16, 16], labelfont = [16, 16], axes = boxed)

Hi there, 

I have this issue when I try to name my label to Dm1 I get back "VectorCalculus:-Dm1". I know that after I have the figure, I can manually change it but I have many of them and want to save them automatically, therefore it would be necessary to immediately get the right label. 

Are there any suggestions? Maybe a different way, how to write subscript?

 

Thank you for your help!

 

I solved this linear constant coefficients ode by hand, and wanted to use Maple to check my solution.

dsolve works with no problem. I wanted to check the particular solution on its own, so called DEtools:-particularsol(ode,y(x)); but was surprised it hangs.

Why would DEtools:-particularsol(ode,y(x)); hang, when dsolve gives the complete solution (including particular solutin ofcourse) right away?  It is 7th order ODE. But nothing special. Linear and constant coefficients. Since dsolve solves it right away, I expected DEtools:-particularsol to have no problem as well.

restart;
ode:=diff(y(x),x$7)-2*diff(y(x),x$6)+9*diff(y(x),x$5)-16*diff(y(x),x$4)+24*diff(y(x),x$3)-32*diff(y(x),x$2)+16*diff(y(x),x)=exp(2*x)+x*sin(x)+x^2;

dsolve(ode);  #no problem.

#this hangs. Why?
DEtools:-particularsol(ode,y(x));


 

interface(version);

`Standard Worksheet Interface, Maple 2020.1, Windows 10, July 30 2020 Build ID 1482634`

Physics:-Version()

`The "Physics Updates" version in the MapleCloud is 851. The version installed in this computer is 847 created 2020, October 17, 17:3 hours Pacific Time, found in the directory C:\Users\me\maple\toolbox\2020\Physics Updates\lib\`

restart;
ode:=diff(y(x),x$7)-2*diff(y(x),x$6)+9*diff(y(x),x$5)-16*diff(y(x),x$4)+24*diff(y(x),x$3)-32*diff(y(x),x$2)+16*diff(y(x),x)=exp(2*x)+x*sin(x)+x^2;

diff(diff(diff(diff(diff(diff(diff(y(x), x), x), x), x), x), x), x)-2*(diff(diff(diff(diff(diff(diff(y(x), x), x), x), x), x), x))+9*(diff(diff(diff(diff(diff(y(x), x), x), x), x), x))-16*(diff(diff(diff(diff(y(x), x), x), x), x))+24*(diff(diff(diff(y(x), x), x), x))-32*(diff(diff(y(x), x), x))+16*(diff(y(x), x)) = exp(2*x)+x*sin(x)+x^2

#this works
sol:=dsolve(ode)

y(x) = (5/16)*x+(1/128)*exp(2*x)+(1/8)*x^2-(1/4)*exp(-(2*I)*x)*_C3-(1/4)*exp((2*I)*x)*_C3-exp(x)*_C4+(1/8)*exp(-(2*I)*x)*_C5+(1/8)*exp((2*I)*x)*_C5+((1/36)*I)*exp(-I*x)-((1/36)*I)*exp(I*x)-((67/57600)*I)*exp(-(2*I)*x)+((67/57600)*I)*exp((2*I)*x)+((1/4)*I)*exp(-(2*I)*x)*_C5*x-((1/4)*I)*exp((2*I)*x)*_C5*x+(67/28800)*x*exp((2*I)*x)+(67/28800)*x*exp(-(2*I)*x)-(1/4)*exp(-(2*I)*x)*_C6*x-(1/4)*exp((2*I)*x)*_C6*x-((1/36)*I)*exp(I*x)*x+((1/36)*I)*exp(-I*x)*x+((67/21600)*I)*exp(-(2*I)*x)*x+((1/4)*I)*exp(-(2*I)*x)*_C2+((1/8)*I)*exp(-(2*I)*x)*_C6-((67/21600)*I)*exp((2*I)*x)*x-((1/4)*I)*exp((2*I)*x)*_C2-((1/8)*I)*exp((2*I)*x)*_C6+(67/43200)*exp((2*I)*x)+(67/43200)*exp(-(2*I)*x)+(1/54)*exp(-I*x)+(1/54)*exp(I*x)+_C4*exp(x)*x+(1/48)*x^3+_C7+_C1*exp(x)

#this hangs. Why?
DEtools:-particularsol(ode,y(x));

 


 

Download particular_sol.mw

Here is a division-by-zero bug in a solution produced by pdsolve.  Admittedly, this sort of problem can be difficult to avoid in a CAS, but here it is, in case there is a chance to get it fixed somehow.

restart;

kernelopts(version);

`Maple 2020.1, X86 64 LINUX, Jul 30 2020, Build ID 1482634`

pde := diff(u(x,y,t),t,t) = diff(u(x,y,t),x,x) + diff(u(x,y,t),y,y);

diff(diff(u(x, y, t), t), t) = diff(diff(u(x, y, t), x), x)+diff(diff(u(x, y, t), y), y)

bc := u(x,0,t)=0, u(x,1,t)=0, u(0,y,t)=0, u(1,y,t)=0;

u(x, 0, t) = 0, u(x, 1, t) = 0, u(0, y, t) = 0, u(1, y, t) = 0

ic := u(x,y,0) = x*y*sin(Pi*x)*sin(Pi*y),  D[3](u)(x,y,0)=0;

u(x, y, 0) = x*y*sin(Pi*x)*sin(Pi*y), (D[3](u))(x, y, 0) = 0

pdsol := pdsolve({pde, bc, ic});

"pdsol:=u(x,y,t)=(&sum;) (&sum;)-(2 sin(n Pi x) sin(n1 Pi y) cos(Pi sqrt(n^2+n1^2) t) ({[[Pi^2,n=1],[-(8 n ((-1)^n+1))/((n-1)^2 (n+1)^2),1<n]]) n1 ((-1)^n1+1))/(Pi^4 (-1+n1)^2 (n1+1)^2)"

eval(pdsol, infinity=4);
value(%);

"u(x,y,t)=(&sum;) (&sum;)-(2 sin(n Pi x) sin(n1 Pi y) cos(Pi sqrt(n^2+n1^2) t) ({[[Pi^2,n=1],[-(8 n ((-1)^n+1))/((n-1)^2 (n+1)^2),1<n]]) n1 ((-1)^n1+1))/(Pi^4 (-1+n1)^2 (n1+1)^2)"

Error, (in SumTools:-DefiniteSum:-ClosedForm) summand is singular in the interval of summation

 

 

 

Download pdsolve-bug.mw

 

I was saying to myself today, that one nice thing in Maple, is that it has good type system so one can check type of arguments aginst wrong types being used in the call.

So I was surprised when I called ArrayTools:-AllNonZero  using list as argument, where this function is supposed to accept only Matrix,Vector or Array. And it worked.  But it gave wrong answer at the same time.

Am I doing something wrong here? Should not have this call failed to go through?

restart;
interface(warnlevel=4);
kernelopts('assertlevel'=2):

A:=[0,0,0];
ArrayTools:-AllNonZero(A)

Maple replied 

                       true

But 

A:=Array([0,0,0]);
ArrayTools:-AllNonZero(A)

Now Maple gives the expected result  false

The question is why Maple did not detect the wrong type? Should it have detected wrong type?

And why it even gave wrong answer (but this is not as important, since the call should not be allowed in first place).

btw, this applied to all the other API's listed

 

 

I found a new strange thing with odetest that I have not seen before.

Would you say that these two solutions are the same or not?

They look the same to me.  One just have all the terms on one side, that is all.

Why would Maple odetest verify the first one but not the second? I did not know that all terms have to be on one side before. Is this documented somewhere?

Please see worksheet below.

restart;

interface(version);

`Standard Worksheet Interface, Maple 2020.1, Windows 10, July 30 2020 Build ID 1482634`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 847 and is the same as the version installed in this computer, created 2020, October 17, 17:3 hours Pacific Time.`

ode:=diff(y(x), x) - 2*y(x) = 2*sqrt(y(x));
ic:=[y(0)=1];
maple_sol:=dsolve([ode,op(ic)],implicit);
odetest(maple_sol,[ode,op(ic)]) assuming x>0

diff(y(x), x)-2*y(x) = 2*y(x)^(1/2)

[y(0) = 1]

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

[0, 0]

#now move some terms to one side, and odetest no longer verifies it
my_sol:=y(x)^(1/2) = -1+2*exp(x);
odetest(my_sol,[ode,op(ic)]) assuming x>0

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

[diff(y(x), x)-2*y(x)+2-4*exp(x), 0]

#the solution is to put all terms on one side
my_sol:=y(x)^(1/2) = -1+2*exp(x);
odetest(rhs(my_sol)-lhs(my_sol)=0,[ode,op(ic)]) assuming x>0

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

[0, 0]

 


 

Download odetest_issue_oct_18_2020.mw

 

I've been studying the  drawing  of graph lately .    One of the themes is  1-planar graph .

A 1-planar graph is a graph that can be drawn in the Euclidean plane in such a way that each edge has at most one crossing point,  where it crosses a single additional edge. If a 1-planar graph, one of the most natural generalizations of planar graphs, is drawn that way, the drawing is called a 1-plane graph or 1-planar embedding of the graph.

 

 

 

 

 

I know it is NP hard to determine whether a graph is a 1-planar . My idea is to take advantage of some mathematical software to provide some roughly and  intuitive understanding before determining .

Now,  the layout of vertices or edges becomes important.  The drawing of a plane graph is a good example.

G1:=AddEdge( CycleGraph([v__1,v__2,v__3,v__4]),{{v__2,v__4},{v__1,v__3}}):
DrawGraph(G1)
DrawGraph(G1,style=planar)

K5 := CompleteGraph(5);
DrawGraph(K5);
vp:=[[-1,0],[1,0],[-0.2,0.5],[0.2,0.5],[0,1]];
SetVertexPositions(K5,vp);  #modified the vertex position

DrawGraph(K5);

My problem is that I see that  Maple2020 has updated a lot of layouts about DrawGraph  graph theory backpack , and I don’t know which ones are working towards the least possible number of crossing of  each edges of graph . 

Some links that may be useful:

https://de.maplesoft.com/products/maple/new_features/Maple2020/graphtheory.aspx

https://de.maplesoft.com/support/help/Maple/view.aspx?path=GraphTheory/SetVertexPositions

I think the software can improve some calculations related to topological graph theory, such as crossing number of graph, etc.

 

The uploaded worksheet plots conics in polar coordinates.

A circle, parabola and hyperbola all plot correctly, but the plot command for the ellipse displays a shifted circle. What's wrong?

Conic_quandry.mw

Using solve on this example:

restart;
eq:=x^3 - 3*x^2 + 3*x - 1=0;
solve(eq,x);

gives solution x=1, with multiplicty 3

              1, 1, 1

When using PDEtools:-Solve

restart;
eq:=x^3 - 3*x^2 + 3*x - 1=0;
solve(eq,x);
PDEtools:-Solve(eq,x);

it gives

         x = 1

How can one make it show x=1, x=1, x=1 ?

Found that only when using PDEtools:-Solve(eq,x,numeric) it gives 

           x = 1., x = 1., x = 1.

How to make it do the same without using numeric?

Maple 2020.1.1

 

I have been having difficulty with plotting these graphs from Cartesian to Polar. I know that with double integrals there is an inclusion of r when you go from Cartesian to Polar. I think my graph of the function being integrated is correct. I am having difficulty with the command for the shaded region. I know with Cartesian, I can use inequal command to get the right shaded area. Will this command work with polar coordinates? 

I attached the Maple worksheet.

Thank you all for help in advance!

The command Typesetting:-Settings(prime=x,typesetprime=true):  makes diff(y(x),x) gives the latex as y'(x) which is what I wanted.

But I'd like to also be able to turn this off.  The reason is that in my program, I could have different variables in different places, and need to be able to turn this off/on as the program runs.

I know I can change the setting, by calling the above command again, with different variable. But I was looking for a way to turn it off as well. 

Similar to Typesetting:-Suppress  

Is there a way to do that? Actually the best solution would be, is to have the effect of Typesetting:-Settings(prime=x,typesetprime=true): be local to the proc. So if this command is used inside a proc, when leaving the proc, its effect will be automatically removed, as if this command was never issued.

Only when it is issued in global context, it will remain in effect until one does a restart.   Right now, the effect of Typesetting:-Settings(prime=x,typesetprime=true): is global. Even when called from inside a proc.  But this might be hard to implement. Therefore, being just able to turn it off is good for now.

Here is an example

restart;
foo:=proc(expr,x,y)
   Typesetting:-Settings(prime=x,typesetprime=true):
   print(Physics:-Latex(expr));

   #How to turn off the effect of above Typesetting command now?
   #so the following command works as the default setting?

   print(Physics:-Latex(expr));
end proc;


expr:=diff(y(x),x)=3:
foo(expr,x,y);

 

Hi

I am trying to implement a recursive algorithm for matrix inverses, its a seventh-order method

for n to 7 do
    new := (1/16*old) . (120*I + ((A . old) . (735*I + ((A . old) . (-861.*I + ((A . old) . (651*I + ((A . old) . (93*I + (A . (old(-15*I + (A . old)))))))))))));
    old := new;
    print(n);
end do

However I get a error informing me that this is a recursive statment. Which it is, but maple thinks this is a bad thing.

So it is clear that I am doing somthing wrong, Can anyone help me by explaining what I am doing wrong?

Mvh

Eric Ragnarsson

 

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