Maple 2021 Questions and Posts

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

I have just started using the GR functions available in Maple and have struggled to implement locally flat coordinates whilst using an arbitrary metric. I would like Maple to know that the first partial of g_ is 0 but that the second may not be. This knowledge would help simplify down some of the bulky expressions for the Riemann tensor in terms of g_. Any suggestions would be great as I have very little background knowledge with the submodule.


Why do I get 2 wrong answers here?

I see that they are all false but the last answer is close enough for my purposes




"`f__1`(x):=6.-sqrt(-x^(2)+8*x+9.)" = proc (x) options operator, arrow, function_assign; 6.-RealDomain:-sqrt(-RealDomain:-`^`(x, 2)+8*x+9.) end procNULL

  l__ength := solve(10 = int(f__1(x), x = 0 .. l), l) = 8.855609656, -.4725737205, 6.810993084NULL

10 = int(f__1(x), x = 0 .. l__ength[1]) = 10 = 16.02268001"(->)"false

10 = int(f__1(x), x = 0 .. l__ength[2]) = 10 = -1.586294894"(->)"false``

10 = int(f__1(x), x = 0 .. l__ength[3]) = 10 = 10.00000001"(->)"false 




The spectral radius  is maximum of the absolute values of the eigenvalues of the matrix A.  We can use the function SpectralRadius in Student package. But we noticed a sentence in the help document:

The output from this procedure will be as symbolic as computationally feasible. If the exact spectral radius of A is too time-consuming to compute, it may be computed numerically.

This means that SpectralRadius will evaluate the exact value when it can. Anyway, the internal evaluation process will take time. So for the sake of efficiency, we just want the numerical results of the spectral radius of a matrix. 

I tried to write the following function, but I feel that it is not very efficient, especially for solving characteristic polynomials and their roots.  I even feel that there is a way to find the spectral radius without taking the absolute value of all the eigenvalues and ordering them. 

Spectralradius := proc(A::Matrix)
 local Spectrum;
 Spectrum := sort(abs~([fsolve(LinearAlgebra:-
 CharacteristicPolynomial(A,x)=0,x )]),`>`);
end proc:


One example: In general, the matrices I encounter come from adjacency matrices of graphs, which are always real symmetric. So their eigenvalues are always real. But the Eigenvalues command very slow because it's always trying to get the exact value. So If we use Eigenvalues  to find all the eigenvalues and then sort them, it will be very slow.  Thus  I'm thinking about finding the numerical results.



Vector(4, {(1) = -1, (2) = (1/3)*(1+(3*I)*sqrt(111))^(1/3)+(10/3)/(1+(3*I)*sqrt(111))^(1/3)+1/3, (3) = -(1/6)*(1+(3*I)*sqrt(111))^(1/3)-(5/3)/(1+(3*I)*sqrt(111))^(1/3)+1/3+((1/2)*I)*sqrt(3)*((1/3)*(1+(3*I)*sqrt(111))^(1/3)-(10/3)/(1+(3*I)*sqrt(111))^(1/3)), (4) = -(1/6)*(1+(3*I)*sqrt(111))^(1/3)-(5/3)/(1+(3*I)*sqrt(111))^(1/3)+1/3-((1/2)*I)*sqrt(3)*((1/3)*(1+(3*I)*sqrt(111))^(1/3)-(10/3)/(1+(3*I)*sqrt(111))^(1/3))})



Vector(4, {(1) = -1., (2) = 2.170086486-0.4000000000e-9*I, (3) = -1.481194304-0.5062177830e-9*I, (4) = .3111078169+0.7062177830e-9*I})








Maybe I need a way to find all the numerical eigenvalues of a real symmetric matrix not using  CharacteristicPolynomial or Eigenvalues.


macOS 12.3 + Maple 2021.2

* --> Print
* --> Print to PDF

The created document essentially has no left border (margin). This has been a problem over at least the last three versions in Maple. I end up having to use an extra PDF cropping tool to reset the margins on the document.

What is the solution to this problem?

macOS 12.3 + Maple 2021.2

* select a region on a document
* context click
* --> Copy as image

Copy as image does not put an image on the clipboard.

What is solution?

I describe my problem accurately in mws file. I have a step function

First step. This is f(x) function



f := piecewise(-2 <= x and x < -1, 1, -1 <= x and x < 0, -1, 0 <= x and x < 1/2, 2, 1/2 <= x and x < 1, -2, 0)

piecewise(-2 <= x and x < -1, 1, -1 <= x and x < 0, -1, 0 <= x and x < 1/2, 2, 1/2 <= x and x < 1, -2, 0)


Next step. I try to approximate this function f(x) using wavelet transform, and  I  want to decomposite this function, choose wavelet Haar function and scaling functon  , choose basisn funtion from multiresolution analysis of the Lebesgue space  L^2(R). I choose  such wavelet fucntion `&varphi;`(x) from space MRA V0 and scaling function psi(x)from space MRA V0:NULL

`&varphi;__0` := piecewise(0 < x and x < 1/2, 1, 1/2 < x and x < 1, -1, 0)

piecewise(0 < x and x < 1/2, 1, 1/2 < x and x < 1, -1, 0)


`&psi;__0` := piecewise(0 < x and x < 1, 1, 0)

piecewise(0 < x and x < 1, 1, 0)


After I try approximate initial function f(x), decomposed using such contruction:

"f(x) =(&sum;) (&sum;)`C__m,k` `&varphi;__m,k`(x)  &approx;   f(x) =(&sum;)`C__i` `&varphi;__i` (x-k)"

"f(x) = (&sum;) (&sum;)`D__m,k` `psi__m,k`(x)    &approx;   f(x)=(&sum;)`D__i` `psi__i` (x-k)"

where coeff m shows, space MRA, to which the basis function belongs, and kk shows,basis function shift (x-k)

i.e. I try decompose function respective to basis function, where coeffs calculate the such way:

`C__m,k` = int(f(x)*`&varphi;__m,k`(x), x = -infinity .. infinity)

`D__m,k` = int(f(x)*`&psi;__m,k`(x), x = -infinity .. infinity)

The approximation is considered satisfactory if the following condition is  true:

sup = LinearAlgebra[Norm](f(x)-(sum(sum(`C__m,k`*`&varphi;__m,k`(x), k = 0 .. infinity), m = 0 .. infinity))) and LinearAlgebra[Norm](f(x)-(sum(sum(`C__m,k`*`&varphi;__m,k`(x), k = 0 .. infinity), m = 0 .. infinity))) <= .1

sup = LinearAlgebra[Norm](f(x)-(sum(sum(`D__m,k`*`&psi;__m,k`(x), k = 0 .. infinity), m = 0 .. infinity))) and LinearAlgebra[Norm](f(x)-(sum(sum(`D__m,k`*`&psi;__m,k`(x), k = 0 .. infinity), m = 0 .. infinity))) <= .1

For example `&varphi;__i` calculate that such way:

`&varphi;i` := proc (j, k, t) local a, b, c, m; m := 2^j; a := k/m; b := (k+1/2)/m; c := (k+1)/m; return piecewise(a <= t and t < b, 1, b <= t and t < c, -1) end proc

if `&varphi;__i`the wavelet Haar functions:

`&varphi;__i` := piecewise(a <= x and x < b, 1, b <= x and x < c, -1, 0)

piecewise(a <= x and x < b, 1, b <= x and x < c, -1, 0)


a = k/m, b = (k+.5)/m, c = (k+1)/m

Then vector of Haar functions compute using the follow code:

N := 2^J; `&varphi;d` := Vector(N); H := Matrix(N, N); T := Vector(N); `&varphi;d`[1] := `&varphi;1`(t); for i to N do T[i] := (i-1/2)/N end do; for j from 0 to J-1 do m := 2^j; for k from 0 to m-1 do i := m+k+1; `&varphi;d`[i] := `&varphi;i`(j, k, t) end do end do; for i to N do for j to N do H[i, j] := eval(`&varphi;d`[i], t = T[j]) end do end do


Then integrals

`&approx;`(int(`&varphi;__m,k`(x), x = -infinity .. infinity), `p__d,1`(x)) and `p__d,1`(x) = int(`&varphi;__d`(x), x = 0 .. x) and `&approx;`(int(`&varphi;__d`(x), x = 0 .. x), `P__d `*`&Phi;__d`)

`&approx;`(int(`&psi;__m,k`(x), x = -infinity .. infinity), `p__d,1`(x)) and `p__d,1`(x) = int(`&psi;__d`(x), x = 0 .. x) and `&approx;`(int(`&psi;__d`(x), x = 0 .. x), `P__d `*`&Psi;__d`)

where `P__d ` is an d-square matrix called an operational matrix of integration

pn := proc (i, n, t) if n = 1 then return int(`&varphi;d`[i], t) end if; return int(pn(i, n-1, t)) end proc


And now, it's not working, so I have troubles for calculate coeffs and writing and  plotting this result, so, I have some questions:

1) How to calculate coeffs `C__m,k`and `D__m,k`  for my fucntion f(x) and get value of coeffs?
2) How to implement integration and write the final sum (approximation of function f(x)?

3) How to calculate  

LinearAlgebra[Norm](f(x)-(sum(sum(`C__m,k`*`&varphi;__m,k`(x), k = 0 .. infinity), m = 0 .. infinity)))

LinearAlgebra[Norm](f(x)-(sum(sum(`D__m,k`*`&psi;__m,k`(x), k = 0 .. infinity), m = 0 .. infinity)))

and plot initial function f(x) and approximation sum at one plot?

Do I understand correctly that I need to calculate this integral for my function on each interval of my function?

int(`&varphi;__m,k`(x), x = -2 .. -1); int(`&varphi;__m,k`(x), x = -1 .. 0); int(`&varphi;__m,k`(x), x = 0 .. 1/2); int(`&varphi;__m,k`(x), x = 1/2 .. 1)

int(`&psi;__m,k`(x), x = -2 .. -1); int(`&psi;__m,k`(x), x = -1 .. 0); int(`&psi;__m,k`(x), x = 0 .. 1/2); int(`&psi;__m,k`(x), x = 1/2 .. 1)

How to implement this procedure?

Code for calculating procs a I try ude from this source:


I would be very grateful for any help!

So all I'm trying to do is a simple sequence like seq(i^2, i=1..10, 1) but with units.  The seq function is part of the Units:-Standard and Units:-Simple packages.  I couldn't find any examples with units in the help system.  For my first attempt, I tried to create a simple sequence of values with units using what is, to me, a logical syntax.  I have included the Maple input below.  I bolded the input.

[*, +, -, /, <, <=, <>, =, Im, Re, ^, abs, add, arccos, arccosh, arccot, arccoth, arccsc, arccsch, arcsec, arcsech, arcsin, 

  arcsinh, arctan, arctanh, argument, ceil, collect, combine, conjugate, cos, cosh, cot, coth, csc, csch, csgn, diff, eval, 

  evalc, evalr, exp, expand, factor, floor, frac, int, ln, log,  log10, log2, max, min, mul, normal, polar, root, round, sec, 

  sech, seq, shake, signum, simplify, sin, sinh, sqrt, surd, tan,   tanh, trunc, type, verify]

seq(ii, ii = 1.0*Unit('m') .. 10.0*Unit('m'), 1.0*Unit('m'));

Error, (in Units:-Standard:-seq) wrong number (or type) of parameters in function seq

Can anyone show me the correct syntax for this?  Is there something in the help?  I tried it in 2021 and 2022 with the same result.

I am using Maple 2021.2 on Ubuntu Linux 20.04 LTS. Sometimes the Maple after start does not show Sig in part of top Maple desktop panel. So I need to restart Maple and 2nd or 3rd start is mostly OK. After that is the situation for some time good.

See attached snapshot... Any idea what is wrong?

I set infolevel[dsolve]:=2; and first time I use it, it gives very long output. Next time I use it on same ode with same command it gives much shorter output.

Why is that and how to make it give the shorter output from first call?  This is very strange behavior.  One would expect the same output each time. The worksheet attached shows that first time it is used, the output is very long. At the end of the worksheet the call is made again with same infolevel, and now output is much smaller.

(getting error uploading worksheet. Will try again. Unable to do insert content keep getting error from this site. So I am just attaching it as link. May be due to large size of the worksheet)

The IsSubgraphIsomorphic command accepts either two undirected graphs or two directed graphs as input.  It returns true if G1 is isomorphic to some subgraph of G2. The GraphTheory [IsSubgraphIsomorphic] command was introduced in Maple 2021.

If a graph T is isomorphic to some subgraph T' of  a graph GIsSubgraphIsomorphic(T,G)  will  return true. But there is no option to return T'. That makes it hard to check manually.

I've seen  IsSubgraphIsomorphic behaving strangely lately. I want to check whether K8-P6 contains K7-K3 as its subgraph.

T:=DeleteEdge(CompleteGraph(7),{{1,2},{2,3},{3,1}},inplace= false): 
G:=DeleteEdge(CompleteGraph(8),{{1,2},{2,3},{3,4},{4,5},{5,6}},inplace= false): 


I think theoretically, the result of IsSubgraphIsomorphic is not correct. I also tested it from Mathematica, and it worked as I expected.

h = EdgeDelete[ CompleteGraph[7], {1 <-> 2, 2 <-> 3, 3 <-> 1}]; 
g = EdgeDelete[ CompleteGraph[8], {1 <-> 2, 2 <-> 3, 3 <-> 4, 4 <-> 5, 5 <-> 6}]; 
IsomorphicSubgraphQ[h, g]


I wonder what went wrong.


PS: Subgraph isomorphism is a question I've asked before, and we can refer to the following links and code.

T:=DeleteEdge(CompleteGraph(7),{{1,2},{2,3},{3,1}},inplace= false): 
nE,nV := NumberOfEdges(T), NumberOfVertices(T):
# Produce all subgraphs of G which have the same number of edges and vertices as the "test" sub-graph T
U:=choose(Edges(G),nE): nops(%):
U1:=select(t -> (nops(`union`(t[]))=nV), U): nops(%):
gL:= Graph~(U1): nops(%):
ans:= [ seq
          ( `if`
            ( IsIsomorphic( T, gL[j] ),
if   numelems(ans)>0
then HighlightSubgraph( G, gL[ans[1]], edgestylesheet=[thickness=4, color="Red"]);
     DrawGraph(G, style=spring);

These codes are due to tomleslie  and  vv. According to above codes, it seems that there is something wrong with IsSubgraphIsomorphic too.

I capture the output of dsolve after setting infolevel to some file so I can later read that output and put it in my own document (Latex).

Currently what I do is set infolevel, then use writeto(file_name) to send all the output that would normally go to standard output to the text file, then later do readline to read it back for further processing.

The problem is that Maple does not put the output in the file the same way as it appears on the screen when using worksheet.

For example, all newlines are lost. So everything comes out in one line in the file_name .  I am not sure why that is.

Is there an option or trick to make the output not lose the newlines? It also seems to format things differently in the file. An example will make this clear

When running this code

currentdir("... set the directory to where you want to save the file to ..");

writeto("output_of_dsolve.txt");  #send all output to file
writeto(terminal); #to send output back to terminal

When I open the file output_of_dsolve.txt this is what shows

`Methods for first order ODEs:``--- Trying classification methods ---``trying a quadrature``<- quadrature successful`     solAssignyApplyFunction(x)equalsuminus0cosApplyFunction(x) + _C1, [

       Typesetting:-mprintslash([sol := y(x) = -cos(x) + _C1], 

       [y(x) = -cos(x) + _C1])]


But in the worksheet, when I run the same code without writeto("output_of_dsolve.txt");  so output goes to terminal as normal, here it is how it looks like

Is there a way to keep the newlines? And why there is some extra stuff in the file that do not show on the screen? Should one change the Settings for Display before doing the above? Currently the default I have is typesetting level is "Extended". Do not know if this affects it or not.

Is the above method the only way to capture the output of dsolve from infolevel to a text file? It looks like Maple uses `` in the file in place where there should be a newline (CR) inserted.


I did this experiment but there is still some strange formatting coming out in the file. Here is an example



interface(typesetting=standard): #added this
interface(prettyprint=0):  #added this


And now the text file has this

`Methods for first order ODEs:``--- Trying classification methods ---``trying a quadrature``<- quadrature successful`Typesetting:-mprintslash([(sol := y(x) = -cos(x)+_C1)],[y(x) = -cos(x)+_C1])

What is Typesetting:-mprintslash at the end of the line above? it is duplicate.

And how to get rid of it? Is there another settings to set other than interface(typesetting=standard): and interface(prettyprint=0): ?

I have a set of points. I only want to plot ones with x and y less that 5 units from [0,0]. I can do it with for do loop. Can't get it to work with seq. Ideally I don't want to create another list.



points := [[-.4821957161, -.3251957485], [-1.079859775, -1.473869954], [.7429089919, .1649759550], [1.329939269, 0.7259335832e-1], [-.1254930617, .1268183497], [-10.63408888, -2.637665397], [-0.1855663689e-1, .1572001339], [8.963609684, 7.419424024], [.7724026996, .1662719092], [1.278337644, 0.7583092624e-1]]


" points2:= [seq('if'(" abs"(points[i,1])<5 and abs(points[i,2])<5, points[i] ,0)  ,i=1..10)] "

[[-.4821957161, -.3251957485], [-1.079859775, -1.473869954], [.7429089919, .1649759550], [1.329939269, 0.7259335832e-1], [-.1254930617, .1268183497], [-10.63408888, -2.637665397], [-0.1855663689e-1, .1572001339], `if`(false, [8.963609684, 7.419424024]), [.7724026996, .1662719092], [1.278337644, 0.7583092624e-1]]



redp := plots:-pointplot(points, colour = red, symbolsize = 4, symbol = solidcircle)


plots:-pointplot(points2, colour = red, symbolsize = 4, symbol = solidcircle)

Error, invalid input: `if` expects 3 arguments, but received 2





I have been unsuccessfully switching off the autosaving from Maple 2021. There is no "Options Dialog - General Tab". Please help me. Thank you!

int( exp(-2*r)*cos(theta)^3*r^2*sin(theta), phi=0..2*Pi, theta=0..Pi, r=0..infinity);

This integral with cos(theta) to an odd power should evaluate to zero, as found in Maple 17 [moderator: and up to Maple 2015.2] but not the most recent versions.

Opgave 1)

a = radius 1
b = radius 2
h = højde
Error, unexpected number
a := 213/2;
b := 144/2;
h := 46;
Vi definerer A_g(a,b)= areal af grundfladne, hvor a og b er de to radiusser.
r(u,v) = parametrisering af fladen i rummet
jf = Jacobi for fladen
r(u,v,w) = parametrisering af voluminet i rummet
jv = jacobi for voluminet
v(u0,u1,v0,v1,w0,w1) = voluminet af figuren
A_f(u0,u1,v0,v1) = voluminet af fladen
Error, missing operator or `;`
A_g := (a, b) -> b*a*Pi;
V := (a, b, h) -> 2/3*b*a*Pi*h;
x := (u, v) -> a^cos(u)*sin(v);
y := (u, v) -> b*sin(u)*sin(v);
z := (u, v) -> h*cos(v);
r := (u, v) -> <x(u, v), y(u, v), z(u, v)>;
ru := (u, v) -> diff(r(u, v), u);
rv := (u, v) -> diff(r(u, v), v);
jac := CrossProduct(ru(u, v), rv(u, v));
jf := sqrt(jac[1]^2 + jac[2]^2 + jac[3]^2);
           |               2       4
     jf := |10969344 cos(u)  sin(v) 

               /     cos(u)\                 2           /
               |/213\      |        2   /213\        4   |
        + 2116 ||---|      |  sin(u)  ln|---|  sin(v)  + |
               \\ 2 /      /            \ 2 /            \
         /213\             2   /213\              
     -72 |---|       sin(u)  ln|---| sin(v) cos(v)
         \ 2 /                 \ 2 /              

                                cos(u)       \  |      
                           /213\             |  |      
        - 72 cos(u) sin(v) |---|       cos(v)|^2|^(1/2)
                           \ 2 /             /  /      

      |               2       4                  2       4
jf := \10969344 cos(u)  sin(v)  + 24000201 sin(u)  sin(v) 

     /            2                            2              \ | 
   + \-7668 sin(u)  sin(v) cos(v) - 7668 cos(u)  sin(v) cos(v)/ /^


Opgave b)

A_g(a, b);
                            7668 Pi


V(a, b, h);
                           235152 Pi

                        7.387517958 10 

Opgave b)

Vi skal blot løse integralet for
u \in [0,2*Pi] og v \in [0,Pi/2].

V bestemmer hvor langt z skal gå. Da dette er vores højde, lader vi denne gå til 0. Men ikke længere.
Error, missing operator or `;`
int(jf, [u = -Pi .. Pi, v = 0 .. Pi/2]);


Opgave c)

Humlen er her, blot at definere en f(x,y,z)=z0-hældning*z, hvor:

hældning = df/dz
z0 = f(z=0)

I opgaven får vi
z=0 -> f = 20
z=46 -> f=10

Det er en fastprocentdel, så vi skal bruge eksponentialfunktion:

Hældning := (10/20)^(1/46)

Vi går så m(u,v) = f(x(u,v),y(u,v),z(u,v))

Bagefter, skal vi gange med jacobi og tage integralet.

Error, missing operator or `;`

z0 := 20;
`hældning` := (10/20)^(1/46);
f := (x, y, z) -> 20*`hældning`^z;
m := (u, v) -> 20*(1/2*2^(45/46))^(46*cos(v));

int(m(u, v)*jf, [u = 0 .. 2*Pi, v = 0 .. Pi/2]);

                           129.98 jf

Whenever I run any of the double integrals in this script, Maple freezes out and doesn't come back. What am I doing wrong? Why does it lag so much?

First 9 10 11 12 13 14 15 Last Page 11 of 34