Maple 2021 Questions and Posts

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

We have just issued a critical fix to Maple, MapleSim, and Maple Flow running on macOS.

We have heard from some users who were experiencing serious problems with doubled characters while using Maplesoft products on macOS, including these reports on MaplePrimes. Further investigation determined that these problems appear specifically on macOS 11 and macOS 12.  I am happy to report that we have now corrected the problem, and a patch is available. 

Anyone who uses macOS 11 or macOS 12 should install this update immediately. We also strongly recommend that all macOS users install this update, to avoid problems that may be triggered by future updates to your operating system.

To obtain this update:

For those who have experienced problems, we apologize for the inconvenience and thank you for your patience while we worked to find a solution.

I try to know an equation of the tangent on the point [0.504244923, 0.3781836925] on the hyperbola7*x^2 - 7*y^2 - 12.0*x + 9.0*y + 2.25 - 2*x*y=0.How can I do that? Thank you.

I see that one of the parameters of the  function Graph accepts a Array of neighbors.

So I gave it a try. 

G := GraphTheory:-Graph([1,2],[[2],[1]])

G := `Graph 10: an undirected unweighted graph with 2 vertices and 1 edge(s)`

It looks pretty good. But there's something wrong with the following codes.

G := GraphTheory:-Graph([0,1],[[1],[0]])

Error, (in GraphTheory:-Graph) invalid vertex 0 in list of neighbors

G := GraphTheory:-Graph(["0","1"],[["1"],["0"]])

Error, (in GraphTheory:-Graph) cannot determine if this expression is true or false: 1" < 1 or 2 < "1
 

G := GraphTheory:-Graph(["a","b"],[["b"],["a"]])

Error, (in GraphTheory:-Graph) cannot determine if this expression is true or false: b" < 1 or 2 < "b
 

How to use  Array of neighbors in  Graph  correctly?

 

PS: The source of the problem is that I got the following list of adjacencies of a graph  in Python and I want to convert it to  a graph in Maple. Its vertices are [0,1,2, ..., 9].

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

 

G := GraphTheory:-Graph([$0..9],[[1, 2, 3, 4, 5, 6], 
[0, 2, 3, 4, 7, 8], [0, 1, 3, 5, 7, 9],
 [0, 1, 2, 6, 8, 9], [0, 1, 5, 6, 7, 8],
 [0, 2, 4, 6, 7, 9], [0, 3, 4, 5, 8, 9],
 [1, 2, 4, 5, 8, 9], [1, 3, 4, 6, 7, 9], 
[2, 3, 5, 6, 7, 8]])

Error, (in GraphTheory:-Graph) invalid vertex 0 in list of neighbors

I've got a really bizarre error. In my quite short code, if I do not have the print statement, I get the error message 'Error, (in fib_even_sum) illegal use of an object as a name'. If I do use the print statement, the code runs fine, albeit having printed an unnecessary zero.

Here's the code:

fib_even_sum := proc()::integer:

options threadsafe,autocompile:

uses combinat:

local val := 0, n := 1, FN := 0:

#print(%);

while FN <= 4000000 do:

if type(FN,even) then:

val += FN:

else end if:

++n:

FN := fibonacci(n):

end do:

return val:

end proc:

fib_even_sum();

I can't see what would be making it behave like this; perhaps I'm missing something really obvious?

Hello, everyone! The following results about r has many. I want to put the results together(assume they are equal to  zero) and solve them. So my questions are how to put the results together and solve them? Thank you very much! And have a good day!

restart; w:=1/(4*(exp(1/2)+exp(-1/2))+2*(exp(1/2)+exp(-1/2))^2): g1:=x->sum(a[i]*x^i,i=0..50): for j from 0 to 50 do r:=(1/2+w)*(g1(j+1)+g1(j))-w*(g1(j-1)+g1(j+2))-g1(2*j+1): end do

I am trying to calculate the number of  complete subgraphs K4 of a graph. Based on some similar discussions, like following links,

I wrote the following codes:

NumberOfK4:=proc(g::Graph)
local  n,N, i, j, k,l, g1,G1;
uses GraphTheory;
n:=NumberOfVertices(g);
g1 := RelabelVertices(g, [$ i = 1..n]):
N:=0:
 for i from 1 to n-3 do
    for j from i+1 to n-2 do
         for k from j+1 to n-1 do
             for l from k+1 to n do
                G1:=InducedSubgraph(g1,[i,j,k,l]);
                   if NumberOfEdges(G1)=6 then N:=N+1; fi;
               od;
            od; 
         od;
  od;
N;
end proc:
with(GraphTheory): with(SpecialGraphs):
g:=CompleteGraph(5);
g1:=LineGraph(g);
NumberOfK4(g1)

5

I know the above codes are supposed to be inefficient in terms of speed. We want to improve this codes. One way I know  that is to take advantage of  the efficient graph theory programs such as igraph

Recently I learned how Maple calls external C programs. 

The define_external command links in an externally defined function (for example, from a DLL under Windows, or from a shared library under UNIX), and produces a Maple procedure that acts as an interface to this external function.

From the help documentation, we need to compile the DLL files from the  source of C language. If it is a C program that does not need additional libraries, we can compile successfully, such as help documents

    void mat_mult( double *A, double *B, double *C, int I, int J, int K )
    {
      int i, j, k;
      double t;
      for( i = 0; i < I; ++i )
        for( k = 0; k < K; ++k ) {
          t = 0.0;
          for( j = 0; j < J; ++j )
            t += A[i*J+j] * B[j*K+k];
          C[i*K+k] = t;
    }
    }

No offense, maple has relatively few functions on graph theory so far, while Sage has a strong advantage because of its ability to integrate open network resources. I think sage is considered better for graph theory researchers because of this.

I don't know if Maple has any guidance on integrating a publicly available  graph theory library ,such as igraph . 

Where is the difficulty of using the written source code? And my computer system is Windows 10 , are there any special requirements. If Maple does this better, it might be a wonderful thing for graph theorists.

On my PC I can't see the plus and minus sign in the quotient expression when using Student:-Basics:-LongDivision.

Is this a know display issue and is there to correct it?

Windows 10, Maple 2021.2

interface(version);

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

restart;

A:=4*x^4;
B:=3*x^2-60*x+36;
Student:-Basics:-LongDivision(A,B,x); #NOTICE, no + sign shows in quotient

A := 4*x^4

B := 3*x^2-60*x+36

"[[(`%+`(3 x^2,-60 x,36)),[[,(4 x^2)/3,(80 x)/3,1552/3,],[),4 x^4,,,,],[,(4 x^4-80 x^3+48 x^2)/(),],[,,80 x^3-48 x^2,,],[,,(80 x^3-1600 x^2+960 x)/(),,],[,,,1552 x^2-960 x,,,],[,,,(1552 x^2-31040 x+18624)/(),,,],[,,,,30080 x-18624,,,,]]]]"

rem(A,B,x);
quo(A,B,x); #signs shows up here OK

30080*x-18624

(4/3)*x^2+(80/3)*x+1552/3

 

Download no_signs.mw

 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.

First 18 19 20 21 22 23 24 Last Page 20 of 40