Maple 2020 Questions and Posts

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

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

 

To obtain the columns of matrix as a list, this is what I currently do

A:=Matrix([[1,2,1,3,2],[3,4,9,0,7],[2,3,5,1,8],[2,2,8,-3,5]]);

Now

[seq(A[..,i],i=1..4)];

Also this does it

map(i->A[..,i],[$1..4]);

Is there a "shorter" way to do it?  For example, A[..,[$1..4]] does not do it ofcourse, it just gives the matrix itself back.

 

 

I do not understand what ColumnSpace is doing in Maple, as I can't get it to match my hand solution and the book. It must be using different definition which is not the book standard.

In the textbook, it says to find column space of matrix A, is to find the Echelon form, then lookup the pivot columns. Then pick the corresponding columns from the original A. These are the column space.

I'll show the book example, and Maple code to try to get same answer.

Here is an example from the book

Notice the columns space are the first, second and fourth columns of A. Since these correspond to the pivot columns of the Echelon form.

In Maple, the Echelon is found using LinearAlgebra:-GaussianElimination(A,'method'='FractionFree'); which gives the same pivot columns as the book. So far so good (the numbers are not the same, but this is normal, as Echelon form is not unique. Only reduced Echelon form is unique), but as long as the pviot columns are correct, that is the important part. 

But when I do LinearAlgebra:-ColumnSpace(A); I get completely different result. The only thing I could see in help, is that it says The Vectors are returned in canonical form with leading entries 1.

I do not underand what that means or how to convert Maple answer to make it match the expeted result since the result is completely different and I do not see the mapping needed.

restart;
A:=Matrix([[1,2,1,3,2],[3,4,9,0,7],[2,3,5,1,8],[2,2,8,-3,5]]);
LinearAlgebra:-GaussianElimination(A,'method'='FractionFree');
LinearAlgebra:-ColumnSpace(A);


I also tried this on Wolfram Alpha, and got same answer as the book

 

 

Maple 2020.1

reference: Differential Equations and linear algebra, 4th ed., Edwards, Penney and Calvis. Pearson. 2017. page 247.

(2x+a^2-3a)=a(x-1) with all the real values of a

int(1/(x-1)+sum((k+1)*x^k,k=0..2018)/sum(x^k,k=0..2019),x);

Direct integration produces a large, messy statement, including numbers like 2017, 2016,...,1

Looking at the parts, the numbers 2020, 2019, etc. are in each.

(**) sum((k+1)*x^k,k=0..2018);
x^2019*(2019*x-2020)/(x-1)^2+1/(x-1)^2

(**) sum(x^k,k=0..2019);
x^2020/(x-1)-1/(x-1)

Looks like this should reduct to some simple expession????

Looking at #6 in http://www.mit.edu/~pax/pdf/qualifying_round_2020_test.pdf

How do I entter the continued fraction in Maple?  I am using the command line interface (actually Emacs).

Hello,

I have a question about fitting a function to experiemental data. The experimental data is Di = X(zi) +I*Y(zi) for a zi = [z1 z1+dz ...z1+dz*N], where zi are real values. I want to fit a complex function f(z,a,b,c) to the data zi and Di , where a,b,c are complex-valued parameters. Does someone know how to fit a complex function to a complex data? The Maple function that I found work only with real functions and data.

First 32 33 34 35 36 37 38 Last Page 34 of 55