Maple 2021 Questions and Posts

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

 I have two personal packages I wrote for Maple a few years age. I use them regurlary. They are stored in two differant locations.  Is there of interogerating Maple to find out where they are and some details obout them? What I load is

with(RationalTrigonometry) and with(RonanRoutines)

I finally found them again.

One in C\usersIRonan\Maple\persona\lib\RatTrig.mla

Other in (basically in) My documents\Maple\.A library\RonanRoutines1.mla

So the package load name and the .mla file name are different. I would like to know where the packages are being loaded from and under what name they are saved as.

 


 

 

I am a new user of Maple. I use Mathcad to plot n*n*n 3D mesh as shown in my sheet.

Please show me the way how to plot3D by Maple. I want to make f(n) to make n*n*n 3D mesh with points and lines.

Tokoro.

sum( (-1)^k/k * sin(k*x), k=-infinity..infinity);

  (mathematica solves this instantly.)

Maple users may notice unexpected results when calculating standard deviations with weights.

This is because the notion of weights used by Maple is not exactly the commonly used notion of repeated measurements.

Maple uses the NAG library from the Numerical Algorithms Group to compute the standard deviation in the presence of weights. The formula that is used is given in their documentation: https://www.nag.com/numeric/cl/nagdoc_cl25/pdf/g01/g01aac.pdf.

 

NULL

restart

with(Statistics)

V := `<,>`(seq(i, i = 57 .. 77), undefined)

_rtable[36893489755601713980]

(1)

W := `<,>`(2, 4, 14, 41, 83, 169, 394, 669, 990, 1223, 1329, 1230, 1063, 646, 392, 202, 79, 32, 16, 5, 2, 5)

StandardDeviation(V, weights = W)

HFloat(HFloat(undefined))

(2)

StandardDeviation(V, weights = W, ignore = true)

HFloat(2.7274213984819053)

(3)

NULL

Download standard-deviation-weights-help-example.mw

Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible along each branch before backtracking. see  https://en.wikipedia.org/wiki/Depth-first_search 

Here I write a  DFS function in maple  language according to the principle of  BFS algorithm.  

Pseudo codes:

procedure DFS_iterative(G, v) is
    let S be a stack
    S.push(v)
    while S is not empty do
        v = S.pop()
        if v is not labeled as discovered then
            label v as discovered
            for all edges from v to w in G.adjacentEdges(v) do 
                S.push(w)

Maple DFS codes:

DFS:=proc(g::Graph,x)
local  s,seen,vertex,nodes,w,vertexlist;
s := stack[new]():
stack[push](x, s):
seen :=[x]:
vertexlist:= []:
while not stack[empty](s) do
      vertex:=stack[pop](s):
      vertexlist:= [op(vertexlist),vertex]:
      nodes:= Neighborhood(g, vertex):
      for w in nodes do
            if not evalb(w in seen) then:
                stack[push](w, s):
                seen :=[op(seen),w]:
            end if:
      end do:  
end do:
return  vertexlist
end proc:
with(GraphTheory):with(SpecialGraphs):
P := PetersenGraph():
DrawGraph(P);
DFS(P,1)

[1, 6, 10, 9, 8, 4, 3, 7, 5, 2]

The result of a depth-first search of a graph can be conveniently described in terms of a spanning tree of the vertices reached during the search.

But I haven't figured out how to improve the  above codes to get this DFS spanning tree.

 

PS: The stack seems to be deprecated in maple2021.

As another way to search BFS algorithm, Carl Love  provided an example of the application of BFS algorithm. 

I also wrote a BFS code implementation based on the queue as follows.

BFS:=proc(g::Graph,x)
local  s,seen,vertex,nodes,w,vertexlist;
s:= SimpleQueue():
s:-enqueue(x):
seen :=[x]:
vertexlist:= []:
while not s:-empty() do
      vertex:=s:-dequeue():
      vertexlist:= [op(vertexlist),vertex]:
      nodes:= Neighborhood(g, vertex):
      for w in nodes do
            if not evalb(w in seen) then:
                s:-enqueue(w):
                seen :=[op(seen),w]:
            end if:
      end do:  
end do:
return  vertexlist
end proc:
BFS(P,1)

[1, 2, 5, 6, 3, 9, 4, 8, 7, 10]

 

I am trying to compute the determinant of a 3 x 3 matrix. It has very involved symbolic entries.

The cpu goes to 100% and after about a minute I get BSOD on windows 10. Using a 4 core i7 64 gig of ram.

Can I stop Maple using all the cores to see if this helps the BSOD.?

How do I use ErrorPlots to put error bars on my scatter plot of data, AT THE LOCATION OF THE SCATTER PLOT DATA POINT? Below I write an example demonstrating how I plot the data and error bars using ErrorPlots.  When I use display to combine plots you clearly see that the errorbars are not on the scatter plot data points.  How do I give ErrorPlots, the x-y locations of the data points, so it knows to print the error bars on the location of the data points?  Is there a better approach to putting horizontal and vertical error bars onto scatter plot data?

I try to eliminate m  in                    X := (a*m^2 + 2*m^2*p + 2*p)/(2*m^2)
                                                      Y := a/(2*m)

eliminate({X, Y}, m);
 allvalues(m);
without results. How can I do ? Thank you.

I noticed Maple changes 1/(4*(x-2)) to 1/(4*x-8)  when copying the output and pasting it back to the worksheet.  

But in the variable it does remain 1/(4*(x-2))  which is what I wanted, as I am going to look for this form later on and I do not want it expanded.

But I am curious why Maple does this. It is a little annoying when copying something from one worksheet to another and have it change.  Here is a small movie and the code to see it. 

Is there a way to prevent this automatic expansion?  Maple 2021.2 on windows 10

 

code

r:=(x^4-8*x^3+24*x^2-24*x+12)/((4*x^2*(x-2)^2)):
rf:=convert(r,fullparfrac,x);

I use worksheet interface and have my display settings as the following

As a Maple user for 10+ years, I've had plenty of stack limit errors, pretty much all of them my fault. But I am currently experiencing a very unusual one after updating my Mac from Maple 2019 to Maple 2021.2.

I am running a long script to fetch json data from a url, parse it, and do a bunch of analysis. In most cases it works fine, but some cases give either an "Execution stopped: Stack limit reached." error, or the error "Error, (in type/polynom) result from type `algfun` must be true or false". Both are being caused by calling the gfun:-ratpolytocoeff command.

I kind of think some internal memory of Maple is being accidentally overwritten because I can cause the error to occur or not occur by adding / commenting out random lines of code that have nothing to do with the part of the code causing the problem. I've managed to find a fairly small script that causes the problem to occur:

with(PolynomialIdeals):
url := "https://api.combopal.ru.is/garpur_run/61e5f7acf2e929ff811caad3":

root_func := F[0, x]:

latex:-Settings(useimaginaryunit=i):

data := URL[Get](url):
json := JSON[ParseString](data):
json := JSON[ParseString](data):

debug_solved := (x^5-3*x^4+5*x^3-7*x^2+4*x-1)/(x^5-5*x^4+10*x^3-10*x^2+5*x-1):

debug_gfun := gfun[ratpolytocoeff](debug_solved, x, n);

If I remove ANY of these lines of code, there is no longer any problem, which is very strange because, for example, I'm not using the PolynomialIdeals package anywhere in the script. This particular script works fine on a Linux machine running 2021.0, but yet I am having similar problems on that machine with other cases.

Here's a slightly simpler example in which gfun[ratpolytocoeff] induces a "division by zero" error ("Error, (in convert/fullparfrac/normal_only) numeric exception: division by zero"):

with(PolynomialIdeals):
url := "https://api.combopal.ru.is/garpur_run/61e5f7acf2e929ff811caad3":

latex:-Settings(useimaginaryunit=i):

data := URL[Get](url):
json := JSON[ParseString](data):
json := JSON[ParseString](data):

debug_gfun := gfun[ratpolytocoeff](1/(1-x), x, n);

After the division by zero error, if I press Ctrl+D to close the Maple command line, it prints
"GC Thread signalAbort 0x7000019a5000 Execution stopped: Stack limit reached.".

Is this an internal Maple bug? Is there any workaround? I am pulling my hair out and would be very grateful for any help.

psi := psi(t)

psi := psi(t);
Error, recursive assignment
How can this assignment be accomplished?

There seems to be a bug in Maple 2021, latest release. Not sure if this was in previous versions.

When checking off the "Show Column Header" in Datatables, the cells are becoming invisible, while the column header still remains.

Show Row Header on the other side works fine.

A user wondered how to have Maple produce a desired form of a solution

eq1 := `&sigma;__2` = P__2/(Pi*r^2)NULL

NULL

r := (1/2)*d

NULL

soln := `assuming`([solve(eq1, {d}, useassumptions)], [`&sigma;__2`::real, d > 0, P__2 > 0])

{d = 2*(Pi*sigma__2*P__2)^(1/2)/(Pi*sigma__2)}

(1)

NULL

Parse:-ConvertTo1D, "first argument to _Inert_ASSIGN must be assignable"

Download question-better-spacing.mw

We suggested the closest they might be able to get is using simplify like so:

 

restart; eq1 := `&sigma;__2` = P__2/(Pi*r^2)
``

``

r := (1/2)*d

``

soln := `assuming`([solve(eq1, {d}, useassumptions)], [`&sigma;__2`::real, d > 0, P__2 > 0])

{d = 2*(Pi*sigma__2*P__2)^(1/2)/(Pi*sigma__2)}

(1)

``

`assuming`([simplify(soln)], [sigma__2::real, P__2 > 0])

{d = 2*P__2^(1/2)/(Pi^(1/2)*sigma__2^(1/2))}

(2)

NULL


Download suggestion.mw

Many times when using the debugger, and hitting the NEXT button I get the message

   Warning, cannot determine statement number; procedure may have changed in-place

The problem is that after this, hitting NEXT will not go to next statement any more. It will bypass and return from the current procedure. but hitting STEP will make it go to next statement, But STEP will also go into next block which I might not want to do.

Only way to fix this is to terminate the debugging session and start all over again.

it is random and comes up in different places. The code in in .mla file and I step through it.

I am sure anyone who have used the buildin debugger have seen this message before. It shows for me many times. 

What causes it and what can one do to not make it show up or clear it up so one does not have to restart the debugging each time it shows up?

Here is a screen shot.  I am also wondering if this happens using the emacs interface to the Maple debugger? I have not used the emacs interface to the debugger before.

Maple 2021.2 on windows 10

 

I can't understand why this error Error, adding lists of different length show up only when removing a print statement!

Why would a print has anything to do with an error message showing up or not?

some context. I wanted to call map on expression, but wanted to collect the result of operating on each indent in a list as map goes through the expression on term after the other. The expression will be type `+`.

I did not know how to do it inside map. So I create separate proc which map call.

Inside this proc, I use list to append to (this will small list, few terms at most).  To be able to do this, I made the list I want to collect thing into a global variable outside the proc.  Everything was working OK, until I remove a print statement  I had inside the proc for debugging.

I am sure there is a better way to do this all (i.e. collect map output into a list) and I am trying to find better way. But my question is: Why would this error shows up only when I remove a print statement from the last line in the proc?

I also notice when removing the line variable declaration global L now both version work with no error, but get warning Warning, (in f) `L` is implicitly declared local which is why I added declaration global L in first place.

Maple 2021.2 on windows 10

interface(version);

`Standard Worksheet Interface, Maple 2021.2, Windows 10, November 23 2021 Build ID 1576349`

restart;

r:=2/(x^2+1)+1/(x^2+1)^2;
L:=[];
f:=proc(Z)
   global L;  
   #do some processing on Z, then collect it into list L
   L:=[ op(L), Z^2];
   #print("op(L) = ",op(L)," Z=",Z);   
end proc:
map(Z->f(Z),r);
L;

2/(x^2+1)+1/(x^2+1)^2

[]

Error, adding lists of different length

[4/(x^2+1)^2, 1/(x^2+1)^4]

restart;

r:=2/(x^2+1)+1/(x^2+1)^2;
L:=[];
f:=proc(Z)
   global L;  
   #do some processing on Z, then collect it into list L
   L:=[ op(L), Z^2];
   print("op(L) = ",op(L)," Z=",Z);   
end proc:
map(Z->f(Z),r);
L;

2/(x^2+1)+1/(x^2+1)^2

[]

"op(L) = ", 4/(x^2+1)^2, " Z=", 2/(x^2+1)

"op(L) = ", 4/(x^2+1)^2, 1/(x^2+1)^4, " Z=", 1/(x^2+1)^2

[4/(x^2+1)^2, 1/(x^2+1)^4]

 

Download why_error.mw

 

Thanks to everyone for the answers and information I did not know that map does process return value from a proc it calls. Good to know.

 

First 14 15 16 17 18 19 20 Last Page 16 of 35