Maple 2021 Questions and Posts

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

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?

I want to generate several graphs  at the same time that can be dynamically adjusted.I tried to write the following code. But it seemed to keep overwriting the previous drawing of graphs in the list g. I only got the last graph K6.

DrawGraph~(g, layout = interactive, layoutoptions = [neutral_color = "pink", initial = spring])

I don't know how to generate  some graphs with dynamically modified layouts at once

Maple uses \begin{array}...\end{array} for the latex of a Matrix, which is all good. But for an empty matrix, it does not generate the column specification c or and so the latex when compiled gives an error. Here is an example


#which gives


Compare to 




Because the c is missing in the first example, this generates an error



>lualatex foo.tex
This is LuaHBTeX, Version 1.13.2 (TeX Live 2021)
 restricted system commands enabled.
LaTeX2e <2021-11-15>
 L3 programming layer <2021-11-12>
Document Class: book 2021/10/04 v1.4n Standard LaTeX document class
For additional information on amsmath, use the `?' option.
(./foo.aux) (/usr/local/texlive/2021/texmf-dist/tex/latex/base/ts1cmr.fd)
! Missing # inserted in alignment preamble.
<to be read again>
l.6 \left[\begin{array}{}


Adding the `c` fixes the Latex.

This came up with my code generated an empty  matrix from some computation.

May be this could be corrected for future version of Maple?

Thank you.

Maple 2021.2 on windows 10.  

Hello Maple gurus!

I have two questions related to working with operands:

Question 1

I often find myself in a situation where I have a non-trivial expression for instance containing double integrals with complex exponentials, and want to perform some operation on a heavily nested operand like the exponent to a specific exponential inside the double integral. Usually what I do is use a list argument with the op() or subsop() to operate on the nested operator by finding specific operand numbers.

However, the problem with this is that I am hard-coding the operand number(s) for the operator, and this expression can be located in the middle of a large worksheet. If something above these op() or subop() calls changes and the changes trickle down, the operands might change number and the commands are no longer valid.

Does Maple have any commands that will let me 'find' an operand like one does in by-hand calculations? For example, there might be an exponent nested in a double integral that has 'a*b' in it. What I want is to operate on the operand containing 'a*b' rather than specifying the actual operand number. Is there anything like this?

Question 2

Somewhat related to the above, I sometimes want to do a single function on multiple operands. I tried applyop but that seems to apply a function to each operand individually. What if, for example, I want to run combine() on 2 specific operands, assuming these operands are heavily nested, to combine just those two operands.

Thank you!

When I convert Maple expression to Latex, before calling Latex, I replace some math names by strings in order to keep them as is in the generated Latex instead of using Maple own shortened name when conversion to latex().

Later on, in the Latex file, I add \DeclareMathOperator on each long name. This way the long math names remain and it is more clear.

This has been working well for years. Same code. No problems. All my Latex was generated this way.

Except just now, I hit a case where Maple's latex() gives an error when the math has WeierstrassP in it. latex() generates exception. 

I will email this also to Maplesoft. But thought to also post it here in case someone can see what the problem is.


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

`The "Physics Updates" version in the MapleCloud is 1165 and is the same as the version installed in this computer, created 2022, March 7, 23:42 hours Pacific Time.`


interface(typesetting=standard); #to prevent bug. see



11*("\WeierstrassP")(x, a, b)*("\WeierstrassPPrime")(x, a, b)/(("\WeierstrassPPrime")(x, a, b)+("\WeierstrassP")(x, a, b)^2)-6*("\WeierstrassP")(x, a, b)^2/(("\WeierstrassPPrime")(x, a, b)+("\WeierstrassP")(x, a, b)^2)+(1/2)*a/(("\WeierstrassPPrime")(x, a, b)+("\WeierstrassP")(x, a, b)^2)


Error, (in latex) unable to proceed; could you please report this problem at




Error, (in TypeTools/nc_var_local) invalid input: member received MathematicalFunctionsNames, which is not valid for its 2nd argument, s



I am getting an exception divide by zero using solve. The problem is that when using kernelopts('assertlevel'=2):  I am no longer able to catch the exception in a catch try.

Removing kernelopts('assertlevel'=2):  I can catch the exception.

But I need to use kernelopts('assertlevel'=2): in my program.   

Is there a way to keep kernelopts('assertlevel'=2): and still catch exception thrown by solve?

Is this a bug in solve? And why using kernelopts('assertlevel'=2): prevents catching the exception?

Using Maple 2021.2 on windows 10. Worksheet attached.

 exception generated




eq:=-A[1]-exp(x^2)*exp(-x^2) = 0;


-A[1]-exp(x^2)*exp(-x^2) = 0

Error, (in unknown) numeric exception: division by zero

Using assertlevel, now unable to catch exception





   eq:=-A[1]-exp(x^2)*exp(-x^2) = 0;
   print("error happend ",lastexception);
end try;
print(" I am here");


-A[1]-exp(x^2)*exp(-x^2) = 0

Error, (in unknown) assertion failed

" I am here"

Not Using assertlevel now can catch exception





   eq:=-A[1]-exp(x^2)*exp(-x^2) = 0;
   print("error happend ",lastexception);
end try;
print(" I am here");


-A[1]-exp(x^2)*exp(-x^2) = 0

"error happend ", unknown, "numeric exception: division by zero"

" I am here"




Update Sept 7,2022

FYI, here is another internal exception generated by solve which shows only when kernelopts('assertlevel'=2): is set, and which can not be trapped using try/catch. May be this could be fixed in future version of Maple. 

Worksheet attached.



`Standard Worksheet Interface, Maple 2022.1, Windows 10, May 26 2022 Build ID 1619613`


`The "Physics Updates" version in the MapleCloud is 1314 and is the same as the version installed in this computer, created 2022, September 2, 15:54 hours Pacific Time.`




eq:=1 = -X*(-(Y^2*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)+2*exp(X*Y)*y0*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*Y+exp(X*Y)*y0^2*exp(X*y0)*exp(x0*Y)*exp(x0*y0))/(exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0+2*Y+2*y0)+(exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*Y+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*y0+1)/(exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0+2*Y+2*y0)^2*(Y*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*y0*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)+Y*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0+exp(X*Y)*y0*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0))/Y/(-(Y*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*y0*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)+Y*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0+exp(X*Y)*y0*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0)/(exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0+2*Y+2*y0)+(exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*Y+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*y0+1)/(exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)*x0+2*Y+2*y0)^2*(X^2*exp(X*Y)*exp(X*y0)*exp(x0*Y)*exp(x0*y0)+2*exp(X*Y)*exp(X*y0)*x0*exp(x0*Y)*exp(x0*y0)*X+exp(X*Y)*exp(X*y0)*x0^2*exp(x0*Y)*exp(x0*y0)+2)):

     sol:=solve(identity(eq,X),[x0, y0]);
end try;

Error, (in unknown) assertion failed







Hello, can someone explain why something like this fails? The help page for 'isolate' says the second argument can be 'any algebraic expression'. Thanks.

I simplified a vector column using side relations. Then I wanted to evaluate using

eval( equation,  [x1=3,  x2=5......})

But side relations uses the reverse order i.e. after evaluation

[3=x1, 5=x2......]

So then the internals of the list need to be swaped tto work with eval.That is easy. I am just wondering is there a neater way to achieve this?



P1 := Vector(3, {(1) = -(y[1]-y[3])*(y[2]-y[3])*((x[2]^2-x[2]*x[3]+x[3]^2)*x[1]^2-x[2]*x[3]*(x[2]+x[3])*x[1]+x[2]^2*x[3]^2)*(y[1]-y[2]), (2) = -(x[1]-x[3])*(x[2]-x[3])*(x[1]-x[2])*((y[2]^2-y[2]*y[3]+y[3]^2)*y[1]^2-y[2]*y[3]*(y[2]+y[3])*y[1]+y[2]^2*y[3]^2), (3) = ((-y[1]^2*y[2]+(3*y[2]*y[3]-y[3]^2)*y[1]-y[2]^2*y[3])*x[2]+x[3]*(y[1]^2*y[3]+y[2]*(y[2]-3*y[3])*y[1]+y[2]*y[3]^2))*x[1]^2+((y[1]^2*y[3]+y[2]*(y[2]-3*y[3])*y[1]+y[2]*y[3]^2)*x[2]^2+3*x[3]*(y[2]-y[3])*(y[1]-y[3])*(y[1]-y[2])*x[2]-x[3]^2*(y[1]^2*y[2]+(-3*y[2]*y[3]+y[3]^2)*y[1]+y[2]^2*y[3]))*x[1]-x[3]*((y[1]^2*y[2]+(-3*y[2]*y[3]+y[3]^2)*y[1]+y[2]^2*y[3])*x[2]-x[3]*(y[1]^2*y[3]+y[2]*(y[2]-3*y[3])*y[1]+y[2]*y[3]^2))*x[2]})

eqns := {(x[1]-x[2])*(x[2]-x[3])*(x[3]-x[1]) = R, (y[1]-y[2])*(y[2]-y[3])*(y[3]-y[1]) = S, x[1]^2*x[2]^2-x[1]^2*x[2]*x[3]+x[1]^2*x[3]^2-x[1]*x[2]^2*x[3]-x[1]*x[2]*x[3]^2+x[2]^2*x[3]^2 = Y, y[1]^2*y[2]^2-y[1]^2*y[2]*y[3]+y[1]^2*y[3]^2-y[1]*y[2]^2*y[3]-y[1]*y[2]*y[3]^2+y[2]^2*y[3]^2 = X, x[1]^2*x[2]+x[1]^2*x[3]+x[1]*x[2]^2-6*x[1]*x[2]*x[3]+x[1]*x[3]^2+x[2]^2*x[3]+x[2]*x[3]^2 = Z, y[1]^2*y[2]+y[1]^2*y[3]+y[1]*y[2]^2-6*y[1]*y[2]*y[3]+y[1]*y[3]^2+y[2]^2*y[3]+y[2]*y[3]^2 = W}

P1new := simplify(P1, eqns)

Vector[column](%id = 36893490132854572084)


values := {x[1] = 3, x[2] = 5, x[3] = 7, y[1] = 2, y[2] = -11, y[3] = 13}

{x[1] = 3, x[2] = 5, x[3] = 7, y[1] = 2, y[2] = -11, y[3] = 13}


vals1 := eval(eqns, values)

{-3432 = S, 16 = R, 120 = Z, 316 = Y, 2018 = W, 22753 = X}


eval(P1new, vals1)

Vector[column](%id = 36893490132854572084)


vals1swap := [seq(rhs(vals1[i]) = lhs(vals1[i]), i = 1 .. nops(vals1))]

[S = -3432, R = 16, Z = 120, Y = 316, W = 2018, X = 22753]


eval(P1new, vals1swap)

Vector[column](%id = 36893490132849052116)


eval(P1, values)

Vector[column](%id = 36893490132871267020)






I was wondering if it is possible to write Maple code in 2D notation inside .mpl and have it converted automatically to standard Maple 1D math.

For example, suppose I have A.mpl file with the content

#--- this is inside A.mpl file


Right now, reading this file in worksheet or even in document mode gives error:

        read "A.mpl"

Error, on line 1, syntax error, unexpected single forward quote:

But in document mode, one can type this in, and Maple will accept it. 

Since I do not use document mode and most of my code is in mpl files, I was wondering if one can write y'(x) instead of diff(y(x),x) and have maple automatically convert the code as it reads it somehow?

I find it much easier and more natural to write   y''(0)=1  than (D@@2)(y)(0)=1  for example.

I do understand the technical problems parsing this as has special meaning in Maple. But Maple does handle this input OK if typed in by hand in document 2D mode. It just needs to extend this to reading it from mpl files.

May be a future release of Maple will support this (using some switches or option when reading the file?)

Is it possible to open or import, and execute Maple Flow documents in Maple 2021?

My OS is Linux/Fedora 35.

Without knowing that Feodra is sadly no more officially supported (it used to be the case a few years ago as I was using it on Fedora) I purchased a standalone license of Maple 2021 and  downloaded the Linux installer but am unable to run the file

from command line (typing 

% sh ./

produces the error "can't execute a binary file") or by clicking on it ("no software installed to run this file").

Before returning the product, I looked at this page to find a possible workaround:

where some tips to install Maple on non-officially supported Linux  os.

I installed lsb packages so that typing:

lsb_relase -a


LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID:    Fedora
Description:    Fedora release 35 (Thirty Five)
Release:    35
Codename:    ThirtyFive

Anyone has succeeded to install Maple 2021 on Fedora? Thank you in advance.

First 11 12 13 14 15 16 17 Last Page 13 of 35