MaplePrimes Questions

Maple (2015) fails to instanciate a Matrix with a list of elements of type string
(for instance Matrix(2, 2, ["A", "B", "C", "D"]) )

Matrix(2$2, [1$4]):    # ok
Matrix(2$2, [A$4]):    # ok

Matrix(2$2, ["A"$4]);  # not correctly understood by Maple (2015) 
Error, (in Matrix) initializer defines more columns (4) than column dimension parameter specifies (2)

Is this a bug?
Maybe something corrected in earlier versions?

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]

 

Hello, which operator should I use instead of ":=" (assignment statement) so that the graph H remains unchanged in the code below?

with(GraphTheory);
G := CompleteGraph(4);
DrawGraph(G);
H := G;
DeleteEdge(G, {1, 2}, inplace = true);
DrawGraph(G);
DrawGraph(H);

I am evaluating Maple Flow 20212.2 on a Macbook Air M1 running MacOs Monterey 12.2.

Unfortunately this is being severly hampered because for every keystroke Maple Flow is entering 

that Character twice.  Disabling keyboard autorepeat and restarting Mac or Maple Flow makes no difference.

Anyone got a solution for this?

Good day everyone,

I am having a problem writing a PDE code and it is given an error code

"Error, (in pdsolve/numeric) initial/boundary conditions must be defined at one or two points for each independent variable"

The link is attached below. Please, help. Thanks

PDE_solution.mw

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.?

I bought a subscription for the Maple calculator on google play and the app still wont give me more than 5 steps a day. Does anyone know what the problem could be?

How can i get mapple code for solving Fractional Patfial Differential Equation with Laplace, Adomian and New Iteration Method

Hello,

I want to draw a 2d directionfield with arrows for a differential equation system with three equations. I have tried the following: 

mu := 1/(365*80);
alpha := 20;
psi := 100;
varphi := 2;
K := 100;
theta := 0.5;
sigma := 0.001;

with(DEtools);
with(PDEtools);
beta := 0.3;
des := diff(S(t), t) = (psi + mu)*K - beta*S(t)*In(t) - (mu + varphi + psi)*S(t) + (theta - psi)*V(t) - psi*In(t), diff(V(t), t) = varphi*S(t) - sigma*beta*In(t)*V(t) - (mu + theta)*V(t), diff(In(t), t) = beta*S(t)*In(t) + sigma*beta*In(t)*V(t) - (mu + alpha)*In(t);

phaseportrait([des], [S(t), V(t), In(t)], t = 0 .. 100, [[S(0) = 70, V(0) = 0, In(0) = 30]], V = 0 .. 100, In = 0 .. 100, stepsize = 0.05, arrows = medium, scene = [V(t), In(t)], linecolour = sin(t*Pi/2))

The problem is, Maple plots only the curve for the initial values and not the arrows of the direction field. How can I solve this problem?

Tanks

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?

Hello, 

I have some complicated calculations which result in a lot of 1e(-7) or even 1e(-12). These numbers greatly complicate the expersisions without adding any benefits. 

How do I instrcut Maple to round the calculations to the nearest decimal precision?

I tried "Digits" and "Rounding" and "interface(precisiondisplay)" but none of them get rid of something like 3.343^(-12)* expr. 

I still see such infistimal terms showing up. 

If you're wondering, I am exporting these symbolic terms to Matlab to be used as optimization functions. So, having these extra terms add unnecessary optimization steps. 

Thanks. 

A system of differential equations

But solution I want to express in terms of other specified function

How to dsolve to get a solution that in terms of a list of specified function? For example in terms of sin , cos , Bessel etc ?

Sol := [a(t) = sin(t) + cos(t) , b(t)= sin(t) ....]

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.

The following code works in one worksheet but not in another (where it returns the error in the title). What could be the reason?

[> restart:
    with(plots):
    with(plottools):
    with(ColorTools):
    P:=display(polygonplot([[0,0],[0,1],[1,1],[1,0]], color=red,axes=none,style = polygon)):
[> exportplot("Test.jpg",P, plotoptions="height=30,width=30,quality=90");

In the worksheet (.mw) where it does work, I can't put the code in one command line unless the file is already there, in which case it overwrites.

- I create a function of 2 variables based on Procedures as follows:

Test := proc (a, b)

local z;

if not is({args}, set(numeric)) then return ('procname')('args') end if;

z := a*x^2+b*y^2-3*x+3*y+3;

minimize(z, location)[1]

end proc:

- The function calculates its value if given the specific values of the variables:

Test(2, 2.5) --> 0.975

- But somehow I can't graph this function with the following syntax:

plot3d(Test(a, b), a = 1.0 .. 5.0, b = 2.0 .. 3.0)

- MAPLe 17 issues the following notice: "Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct". And no graphs are drawn

In the same way, MAPLE 15 can plot the graph. Does anyone know what the problem is with MAPLE 2017 and how to fix it?

Sincerely thank

First 341 342 343 344 345 346 347 Last Page 343 of 2426