Maple 12


Maple can be started either with a command line interface or with a graphical user interface.

When you type maple at a console you will get the Maple command line, where the only input mode is 1-D Math. Even character-rendered plotting is possible from here.

When you type xmaple at a console you will get Maple with a graphical user interface. From here you edit Maple documents.

There exist two basic modes a document is entered and viewed, the (more basic and traditional) “worksheet” and a (more graphical) “document” mode. The latter has an underlying worksheet, which is merely displayed differently. You can switch anywhere inside your document between the two modes by choosing “View > Expand Document Block” or “View > Collapse Document Block” respectively.

There are two basic ways of displaying and entering math. “1-D Math” (also called “Maple Notation”) is in plain ascii text form. Input must be terminated by either ; (displays the result) or : (no displaying of the result). “2-D Math” is a more graphical way of entering and displaying actual math notation.

Hitting ‹ENTER› executes the input given. In “document” mode hitting ‹CNTR›+‹=› executes an inline expression and displays the result inline (without additional linebreak). You can hit ‹SHIFT›+‹ENTER› for a new line while postponing the execution of the input. (Don’t forget the semicolon in this case.)

In a “worksheet” or “document” you can go back, change lines and re-execute them by hitting enter.


No succeeding dependent expressions are re-evaluated! Choose “Edit > Execute > Worksheet” to re-execute everything.

In a “worksheet” or “document” you can enter normal (formated) text which is not executed. ‹F5› switches between entering text and math.

‹ESC› shows a list of possible completions. The right mouse button displays a list of sensible operations on the object. Executing such might write something in text and math mode.

Everything following # is a comment and will not be interpreted.

On certain systems everything following ! is passed to the system command line.

% is a placeholder for the previous expression entered. %% and %%% are placeholders for the second and third last expression.

Math operators:

+ Addition
- Subtraction
* Multiplication
/ Division
^ or ** Exponentiation

Built-in variables:

% Most recent expression
%% Second recent expression
%%% Third recent expression

Built-in functions:

sin(), sinh() (hyperbolic) sine
cos(), cosh() (hyperbolic) cosine
tan(), tanh() (hyperbolic) tangent
sec(), sech() (hyperbolic) secant
csc(), csch() (hyperbolic) cosecant
cot(), coth() (hyperbolic) cotangent
exp() exponential
ln() or log() natural logarithm
log[‹b›]() logarithm with base ‹b›
abs() absolute value
sqrt() square root

Built-in constants:

Pi 3.141592...
I imaginary unit
infinity infinity
true and false boolean constants
gamma Eulers constant 0.5772156...

Invoking help

To show help about some command ‹command› type ?‹command›.

Loading packages

with(‹package›) loads the Maple ‹package›. Terminate with : to suppress the output.

unwith(‹package›) unloads the Maple ‹package›.

Expressions and Names

An expression is a string of constants, operators, other expressions, etc. E.g. 3*x^3 - 4*ln(x).

‹name›:=‹expression› defines a reference (“short cut” ‹name›) for an ‹expression›.

Names can contain any letters and numbers and the underscore and are not allowed to start with a number. More complicated names must be enclosed in backticks (`) to be recognized as names, e.g. `f'`, `some name with spaces`. The backtick itself is produced by \'.

The backslash (\) acts as a line continuation character. To use it in a backtick delimited name type \\.

|| is used to concatenate names (strings). E.g. `my test`||name:=2*Pi is the same as `my testname`:=2*Pi.

Any name can be indexed up to any depth by some other name or expression, e.g. the following defines four names:

U[`hi there`]:=3*Pi

indices(U) returns the four first-level indices used above.

U[1]:=5*Pi would overwrite the definition of U[1][20].

type(‹name›, ‹type›) returns true if ‹name› has type ‹type›, where ‹type› is name, indexed, integer, etc.

subs(‹equation›, ‹expression›) will return an expression with the substitution given in ‹equation› made.


‹expression 1›=‹expression 2› is an equation. No definition or assignment is taking place.

‹name›:=‹expression 1›=‹expression 2› defines a reference ‹name› for the equation ‹expression 1›=‹expression 2›.

rhs(‹equation›) and lhs(‹equation›) return the expression on the right hand and the left had side of the ‹equation›.

Data types

restart clears all the allocated variables.

whattype(‹something›) returns the type of ‹something›.

type(‹expression›, ‹type›) returns a boolean reflecting whether the ‹expression› is of type ‹type›.

To convert between certain data types, convert() can be used.


Strings are delimited by ", e.g. "a string". To make a double-dash or a backslash appear in a string type \" or \\ respectively.


Some symbols (e.g. Pi or gamma) are protected by default and can not be assigned. An unprotected symbol can be protected using the protect('‹symbol›') function.

Unknown variables, e.g. x remain symbolic when operating on them.

If some symbol x refers to a different type of object (e.g. equation, function ...) the x:='x' will turn x back into a mere symbol.


Boolean variables take on values true, false or FAIL, where the last value refers to an unknown truth value.

evalb(‹expression›) evaluates the ‹expression› (usually an equation) into a boolean. is(...) and coulditbe(...) are similar functions.


Normally all numbers are stored as a rational expression involving integers, so no roundoff error occurs. Integers can have arbitrary size.

Floating point numbers

If an expression involves floating point numbers (e.g. 3.5) then the result is a floating point number too.

evalf(‹expression›) or evalf(‹expression›, ‹number of digits›) evaluates
‹expression› to a floating point number. The number of digits can also be set globally by setting Digits := ‹number of digits›.

Complex numbers

I (capital i) is used to indicate sqrt(-1).

conjugate(‹z›), Re(‹z›) and Im(‹z›) return the complex conjugate, real part and imaginary part of ‹z›.

evalc(‹expression›) evaluates a complex expression to something like ‹expression1› + I‹expression2›, e.g. with cosine and sine. All symbols in ‹expression› are assumed to be real.


‹expression 1›, ‹expression 2›,‹...› is an expression sequence. You can also use the seq() function, e.g. as:

seq(‹expression(i)›, ‹i› = ‹start›..‹end›)


Lists are sequences enclosed by square brackets [ and ]. Lists are tuples and thus ordered.


Sets are sequences enclosed by curly brackets { and }. Sets are unordered and don’t contain the same element more than once.

Elements from sequences, lists and sets can be obtained by 1-based indexing as
‹data›[‹index›]. For nested data use ‹data›[‹index1›][‹index2›]‹...›.


A function can be defined as follows:

‹name› := (‹variable 1›, ‹variable 2 ...›) -> ‹expression›

Executing a function as ‹name›(‹some expression for variable 1›, ‹some expression for variable 2 ...›) will return an expression with the variables substituted in the function.

map(‹function›,‹data›) returns a sequence, list, vector... which results from applying ‹function› to the sequence, list, vector ... ‹data›.

zip(‹function›,‹data 1›,‹data 2›) returns a sequence, list, vector... which results from applying ‹function›(‹data element 1›,‹data element 2›) for all data elements in ‹data 1› and ‹data 2›.

unapply(‹expression(x)›, x) returns a function ‹expression(x)› which is obtained by interpreting the ‹expression(x)› as a function in x.

?inifcns opens up the help window with a list of initially known functions.

Many basic functions like Int or Sum have two versions, a regular one (starting with a small letter) and an “inert” one (starting with a capital letter). The latter “inert” version is not evaluated. In 2-D Math mode it is displayed gray integration or summation symbol. Inert functions prevent Maple from trying to evaluate an argument, e.g. to evalf(...) and thus shortens computation time.

There exist compound functions like evalf/int which in this case is integration followed by floating point evaluation.

Functions can be composed from other functions by means of addition, multiplication or with the function concatenation operator @. (‹function1›@‹function2›)(‹variable›) is the same as ‹function1›(‹function2›(‹variable›)). ‹function›@@‹n› concatenates the ‹function› ‹n› times.

Printing to the Screen

print(‹expression›) usually prints the ‹expression› in 2-D Math output mode, which is the same as just writing ‹expression›. In this case, trailing colon : prevents printing.

Statements are recognized in levels, determined by the nesting of conditional or repetition statements and the nesting of procedures. The outermost (interactive) level is level 0. printlevel:=‹level› sets the highest level for which the output of ‹expression›s are still printed. If you are somewhere in a deeply nested loop or procedure and would like to print something use print(...) directly on the object.

Flow control

In the descriptions below, [...] indicates an optional part of code.

For loop:

for ‹k› from ‹start› [by ‹step›] [to ‹end›] [while ‹condition›] do
end do;

While loop:

[for ‹k› in ‹expression›] while ‹condition› do
end do;

If statement:

if ‹condition 1› then
  ‹statements 1›
[elif ‹condition 2› then
  ‹statements 2›]
  ‹statements 3›]
end if;


interface(verboseproc=2) changes the behavior of the print(...) procedure, such that print(‹procedure›) prints the whole code of the ‹procedure› as it is defined.

A procedure is defined as follows:

‹name› := proc(‹argument 1›, ‹argument 2›, ...) [option ‹option›]
   end proc;

For recursive procedures the option remember is sensible. This option lets Maple remember previously calculated results, which - in recursive procedures - might be needed in later recursions. (E.g. Fibonacci sequence)

Type checking can be done in the procedure definition by adding properties to the arguments as ‹argument›::‹property›, e.g. x::integer.

Files and Scripts

save ‹variable 1›, ‹variable 2›, ... ‹filename› saves the variables to a file. load ‹filename› loads all variables from a file. Possible filename extensions are .m (binary Maple data) or .mpl (human readable but also readable by Maple).

A Maple script is a text file with 1-D Math notation instructions to Maple. Every line must be preceded with >. The read command will immediately execute the read code.

Symbolic computation

Converting expressions

normal(‹expression›) converts the ‹expression› into factored normal form, i.e. into a rational expression where the numerator and denominator are relatively prime. If called with a second argument expanded this yields expanded polynomials in the numerator and denominator.

simplify(‹expression›) tries to simplify the ‹expression›. As a second optional argument a simplification rule can be given, e.g. trig applies trigonometric relations.

expand(‹expression›) multiplies terms out and does other expansions. The result needn’t be more complex.

factor(‹expression›) tries to convert the ‹expression› into factors. (The opposite of expand(...)).

collect(‹expression›,‹var›) collects the ‹var›iable. To collect several variables, a list can be given.

normal(‹expression›) puts fractions in ‹expression› onto the same denominator.

coeff(‹expression›,‹var›,‹number›) returns the coefficient of ‹var› raised to the power ‹number›. ‹number› can be omitted.

convert(‹expression›, parfrac, ‹variable›) calculates the partial fraction expansion of ‹expression› in ‹variable›, e.g:

> convert(1/(z-1/5)/(z-2),parfrac,z);
      5           25
  --------- - -----------
  9 (z - 2)   9 (5 z - 1)

convert(‹expression›,radical) replaces RootOfs of polynomials by radical notation if possible.

convert offers many other forms of symbolic conversion.

Symbolic Properties

assume(‹property(x)›) or assume(‹x›, ‹property›) makes Maple assume some property on a variable, e.g. assume(x>0), assume(y, 'real'). about(‹x›) tells what was assumed on ‹x›.

‹x› := '‹x›' removes the assumptions.

The RealDomain package makes global assumptions on all symbols to be real. This package is not compatible with the use of the assume() function.

Integer Computation

ifactor(‹number›) returns a factorization of ‹number› into prime numbers.

Solving equations

solve(‹set of equations›, ‹set of variables›) tries to solve the ‹set of equations› with respect to the ‹set of variables›. Polynomials with degree beyond 4 are in general not solvable.

fsolve(‹set of equations›, ‹set of variables›) solves the equations numerically with Newtons method.

fsolve(‹set of equations›, ‹set of variables›, ‹set of intervals›) searches for the solution within the intervals given, where an interval is written as ‹x›=‹ax›..‹bx›. If ‹set of variables› contains only one variable then ‹x›= can be omitted.

fsolve(‹set of equations›, ‹set of variables›, complex) allows complex solutions.


diff(‹expression(x)›, ‹x›) computes the derivative of ‹expression(x)› with respect to ‹x›.

diff(‹expression(x)›, ‹x›$‹n›) computes the ‹n›‘th derivative.

diff(‹expression(x,y,...)›, ‹x›$‹nx›, ‹y›$‹ny› ‹...›) computes the ‹nx›‘th partial derivative with respect to ‹x›, the ‹ny›‘th partial derivative with respect to ‹y›, ... of ‹expression(x,y,...)›.

D(‹function›) returns a function which is the derivative of ‹function› (in one variable).

D[1$‹n›](‹function›) returns a function which is the ‹n›‘th derivative of ‹function› (in one variable).

D[‹i›$‹n›](‹function›) returns a function which is the ‹n›‘th partial derivative with respect to the ‹i›‘th variable of ‹function› (in several variables). If $‹n› is omitted ‹n› is assumed to be 1.

D[‹i›$‹ni›,‹j›$‹nj›,‹...›](‹function›) returns a function which is the ‹ni›‘th partial derivative with respect to the ‹i›‘th variable, the ‹nj›‘th partial derivative with respect to the ‹j›‘th variable, ... of ‹function› (in several variables).


int(‹expression(x)›, ‹x›) computes the indefinite integral of ‹expression› with respect to ‹x›.

int(‹expression(x)›, ‹x›=‹a›..‹b›) computes the definite integral of ‹expression› with respect to ‹x› between ‹a› and ‹b›.

Differential equations

A differential equation can be constructed with = and diff as a normal equation, e.g. eq := diff(y(x),x$2)-2*diff(y(x),x)=sin(x).

dsolve(‹diffequation(function)›, ‹function›) tries to solve the ‹diffequation(function)› with respect to ‹function›, e.g: dsolve(eq, y(x)).

dsolve({‹diffequation(function)›, ‹initial conditions›}, ‹function›) tries to solve the ‹diffequation(function)› conforming with the ‹initial conditions› with respect to ‹function›. Initial conditions can be ‹function› values (e.g. f(0)=0) or values of ‹function› derivatives. The syntax for the latter is:

D(‹function name›)(‹function variable›)=‹function value›


D(‹function name›@@‹n›)(‹function variable›)=‹function value›

for the ‹n›‘th derivative, e.g: init := y(0)=1, D(y)(0)=1; dsolve({eq, init}, y(x)).

An additional second or first argument numeric finds a numeric solution to the differential equations. The DEtools package provides more sophisticated control.


limit(‹expression›, ‹x›=‹lim›) tries to compute the limit of ‹expression› as ‹x› goes to ‹lim›.

An optional third argument gives the ‹direction›. This can be either right, left, real or complex. The default is the real bi-directional limit unless ‹lim› is plus or minus infinity.

The LinearAlgebra package

<‹a›,‹b›,‹...›> creates a vector from the elements ‹a›, ‹b›... which potentially can be vectors on their own.

Vector(‹n›, ‹list›) creates a length-‹n› vector from the optional ‹list› which can contain vectors.

‹vector›[‹n›] retrieves the ‹n›‘th element of the ‹vector›. ‹vector›[‹n›..‹m›] retrieves the sub-vector. Indexing is 1-based.

ZeroVector(‹n›) constructs a length ‹n› zero-vector.

<<‹a›,‹b›,‹...›>|<‹x›,‹y›,‹...›>|‹...›> creates a matrix from the elements
‹a›, ‹b›, ‹x›, ‹y›... which can be matrices on their own.

Matrix(‹n›, ‹m›, ‹list›) specifies an ‹n› times ‹m› matrix with elements given in the optional (nested) ‹list› which can contain matrices. Indexing is 1-based.

IdentityMatrix(‹n›) constructs an ‹n› times ‹n› identity matrix.

Array(‹start1›..‹end1›, ‹start2›..‹end2›) yields an undefined matrix with row indices ‹start1› to ‹end1› and column indices ‹start2› to ‹end2›. Array is a more general constructor for matrices than Matrix.

SwapRow(‹matrix›, ‹i›, ‹j›)``(``Swapcol(‹matrix›, ‹i›, ‹j›)) returns a matrix with swapped rows(columns) ‹i› and ‹j›.

Matrices and vectors can be added, subtracted, multiplied and taken to a power using the symbols +, -, . and ^.

DotProduct(‹vector 1›, ‹vector 2›) and CrossProduct(‹vector 1›,‹vector 2›) evaluate the dot- and crossproduct of ‹vector 1› and ‹vector 2›.

Transpose(‹matrix›), Determinant(‹matrix›), Trace(‹matrix›), MatrixInverse(‹matrix›), Eigenvalues(‹matrix›), Eigenvectors(‹matrix›) do what their name says.


Plots are shown on the worksheet and can be adjusted by clicking on them and working with the tools appearing in the menu-bar.

plot(‹expression(x)›,‹x›=‹start›..‹end›) creates a 2-D plot of the ‹expression(x)› in the specified range.

To plot a ‹function› the plot command looks like:


The range on the y-axis can be given as a third argument ‹y›=‹start›..‹end›. The ‹x› and ‹y› determine the labels.

A list of data points is a list of two-element sub-lists containing the x and y coordinates of the points, e.g. ‹list› = [[‹x1›,‹y1›],[‹x2›,‹y2›]‹...›]. These points can be plotted by plot(‹list›).

plot() can take further arguments in the style plot(‹...›, ‹attribute›=‹value› ‹,...›).

Plot attributes:

‹attribute› ‹value› comment
style line, point, patch general graph style
color blue, red, black, ... many! See ?plot,colornames
labels [‹x-label›,‹y-label›] the axes label
linestyle ‹integer› 0: solid, 2: dots and dashes, 3: dashes
symbol circle, point, box, cross, diamond  
Title ‹string› the axes title

Multiple plots on the same axis can be done by giving a list of expressions (or functions):

plot([‹expression1(x)›,‹expression2(x)›,‹...›], ‹x›=‹start›..‹end›)

Plotting attributes are set for each line by giving the ‹values› in a list.

Plotting in 3-D is similar to 2-D:

plot3d(‹expression(x,y)›, ‹x›=‹x start›..‹x end›, ‹y›=‹y start›..‹y end›)
plot3d(‹function›(‹x›,‹y›), ‹x›=‹x start›..‹x end›, ‹y›=‹y start›..‹y end›)

The plots package

Multiple plots can be done as follows:

‹name1› := plot(‹expression1(x)›, ‹x›=‹start›..‹end› ‹, attribute = value, ...›):
‹name2› := plot(‹expression2(x)›, ‹x›=‹start›..‹end› ‹, attribute = value, ...›):
display(‹name1›, ‹name2›)

The trailing : is not essential but simply suppresses an echoing of the defined names.

textplot([‹x›, ‹y›, ‹string›]) plots the ‹string› (enclosed within back-ticks `) at the coordinates ‹x›/‹y›. An additional argument align=‹a› can be given where ‹a› is above, below, left, right or a set thereof.

animate(‹expression(x,t)›, ‹x›=‹start›..‹end›, ‹t›=‹start›..‹end›) with possible attribute frames=‹number of frames› creates an animation. There is a similar animate3d.

Java and Printing

Both Maple 12 and Maple 13 refused to show a printing dialog box on my 64-bit Linux. The culprit seems to be the java VM which ships with Maple. It is however simple to advise Maple to use a different JVM. All you have to do is to change two lines in the start-up script ‹Maple root directory›/bin/maple.

In my case I wanted to use the JVM provided by sun. I had to locate the case "bin.X86_64_LINUX") and changed the two lines:




After this, printing worked.