LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=Getting startedMaple commands must be typed after the prompt [ >. Ending the statement with a semicolon (i.e. ;) displays the output, while ending the statement with a colon (i.e. :) suppresses the output. To execute a command press the Enter or Return key.<Text-field style="Heading 1" layout="Heading 1"></Text-field>2;2:LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=You can add multiple lines to an execution group by pressing Shift Enter. The [ shows the size of the execution group.<Text-field style="Heading 1" layout="Heading 1"></Text-field>2;
2:Maple has a built-in help support. You can either go to the Help menu and search for a desired topic or command, or if you already know the command, e.g. sqrt, then you can instead type ? sqrt to bring up the relevant help page.<Text-field style="Heading 1" layout="Heading 1"></Text-field>? sqrtLUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=OperatorsMaple uses the standard notations for all the operators. Blank spaces between the numbers and the operators may be neglected.<Text-field style="Heading 1" layout="Heading 1"></Text-field>4 + 2;4 - 2;4 * 2;4 . 2;4 / 2;4 ^ 2;4 ** 2;LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=When using decimal points, be careful with the blank spaces because . is also an operator to performs a multiplication or dot product.<Text-field style="Heading 1" layout="Heading 1"></Text-field>2.5;2. 5;2 . 5;2 .5;JSFHLUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=Assign and unassignTo assign a value to a variable the command := is used.<Text-field style="Heading 1" layout="Heading 1"></Text-field>x := 2;y := 3*x;LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=To unassign a value to a variable, use the unassign command.<Text-field style="Heading 1" layout="Heading 1"></Text-field>x := 2;unassign('x');x;LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=To clear allt he stored information, u the command restart.<Text-field style="Heading 1" layout="Heading 1"></Text-field>restart;JSFHLUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=JSFHSpecial constantsMaple has a number of protected characters and words. For a complete list, see the help pages ? initialfunctions and ? initialconstants.<Text-field style="Heading 1" layout="Heading 1"></Text-field>I;infinity;Pi;exp(1);LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=Common mathematical functionsMaple has many built-in mathematical functions, such as sin, cos, exp, sqrt, abs, etc. For a full list see ? initial functions.<Text-field style="Heading 1" layout="Heading 1"></Text-field>sin(Pi/2);cos(Pi/2);exp(1);sqrt(4);abs(-5);EvaluationWhen using special constants, such as Pi, Maple will by default represent them by their symbol, \317\200, and not by their numerical value, 3.141592654. To obtain the value of a constant, you need to ask Maple to evaluate it using the function evalf, which converts an expression from it\342\200\231s symbolic form into it\342\200\231s numeric floating-point form.<Text-field style="Heading 1" layout="Heading 1"></Text-field>Pi;evalf(Pi);LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=Maple represents fractions in rational form, to obtain the numerical value we also use the evalf function. Maple automatically converts an expression to it\342\200\231s numerical decimal value if
the expression contains a decimal number.<Text-field style="Heading 1" layout="Heading 1"></Text-field>10/7;evalf(10/7);10/7.0;LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=Other evaluation functions are eval and evalb to evaluate at a point and to determine the boolean value of an expression.<Text-field style="Heading 1" layout="Heading 1"></Text-field>eval(x^2 + 1, x=3);evalb(2<3);LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYjLUkjbWlHRiQ2I1EhRic=If you want to substitute values or expressions in an equation or expression, we use the subs command.<Text-field style="Heading 1" layout="Heading 1"></Text-field>w := a*b+b-3*c;
subs(a=2,w);subs([a=2],w);subs(a=2,b=3,c=2,w);z := 6*u*v^2-3*v+3*exp(v-u);
subs(u=2,v=2,z);eval(z,[u=2,v=2]);JSFHDigitsIn floating-point calculations the default number of digits is 10, this can be changed through the variable Digits.<Text-field style="Heading 1" layout="Heading 1"></Text-field>Digits;evalf(Pi);Digits := 5;evalf(Pi);JSFHSets, lists and sequencesIn Maple there are two different ways to order a sequence of espressions, namely a list and a set.A list is an ordered sequence of expressions [a,b,c,...]. Lists do not remove duplicates. The commands nops and op can be used to obtain the number of list elements and these elements themselves. To select the elements of a list, we use [#]. The command remove may be used to remove elements from a list.<Text-field style="Heading 1" layout="Heading 1"></Text-field>L := [1,3,3,5,7];op(L);nops(L);L[2];L2 := [op(L),10];remove(has,L2,5);JSFHA set is an unordered sequence of expressions {a,b,c,...}. Sets do remove duplicates. The commands nops and op can be used to obtain the number of set elements and these elements themselves. To select the elements of a set, we use [#]. The commands union and minus may be used to add and remove elements from a set. JSFH<Text-field style="Heading 1" layout="Heading 1"></Text-field>S := {5,3,1,7,3};op(S);nops(S);S[2];S2 := S union {4};S3 := S2 minus {5};JSFHOften the command seq, to create sequences, is used in conjunction with sets and lists. <Text-field style="Heading 1" layout="Heading 1"></Text-field>L1 := [seq(i,i=1..5)];L2 := [seq(2*i+1,i=1..5)];S := {seq(L1[i]+L2[i],i=1..3)};JSFHJSFHJSFHSummation and productIn order to compute the sums and/or products of the elements of a list, set or sequence we can use the commands add and mul. In Maple we can also use the commands sum and product, however, these are used to retrieve a formula for the sum and product, while the commands add and mul just compute the sum and product by simply adding or multiplying the the finite sequence of terms. If Maple is unable to retrieve this formula, the function call is returned.<Text-field style="Heading 1" layout="Heading 1"></Text-field>add(i,i=1..6);L := [1,3,5];
add(L[i],i=1..3)sum(i,i=1..n);sum(n^k/(n-1),n=2..k);mul(i,i=1..6);L := [1,3,5];
mul(L[i],i=1..3);product(i,i=1..n);JSFHJSFHArrays, vectors and matricesIn early versions of Maple only arrays could be constructed, however, from Maple 9 onwards, also the data structures Vector andmMatrix were introduced. Arrays are useful when we want to store or manipulate higher dimensional data, however, when you are working with one- or two-dimensional data it is recommended to use Vector and Matrix.In the case of arrays, we need to define the dimension of the array and the range of each dimension. Referring to elements of the array is done by [#,#,...,#]. You can also assign initial values to the array by using lists. You can also perfrom simple arithmic operations, such as element-wise sum, substraction, multiplication and division. Note that matrix multiplication does not work.<Text-field style="Heading 1" layout="Heading 1"></Text-field>A := Array(1..5);B := Array(1..3,1..5);C := Array(1..2,1..3,2);E := Array(1..2,1..3,[[0,3,0],[0,0,-1]]);E[2,3];E + 2*C;E-C;E*C;E/C;C*B;JSFHJSFHVectors are used for one-dimensional data. The difference between Array and Vector is that the operations on vectors must obey linear algebra rules. When constructing vectors, you can specify if you want a column or row vector. The default is a column vector. Alternatively, the < > notation can be used to construct vectors. To convert a row vector into a column vector or vice versa, the convert command is used. The element-wise summation and substraction operators are the same as for arrays. Element-wise multiplication and division are done by *~ and /~. The operator . yields the dot product of 2 vectors. To perform more complicated operations, the package LinearAlgebra needs to be used.<Text-field style="Heading 1" layout="Heading 1"></Text-field>A := Vector(1..3);A := Vector(3);B := Vector(1..3,5);C := Vector[row](1..3,5);E := Vector[column]([1,2,3]);F := <1,2,3>;F[3];convert(A,Vector[row]);B+2*E;B*~E;B/~E;B.E;E.C;JSFHJSFHMatrices are similar to vector, except that they can be both one- and two-dimensional. To refer to an element of a matrix, both the row and column indices need to be specified even in the case of a one-dimensional matrix.<Text-field style="Heading 1" layout="Heading 1"></Text-field>A := Matrix(1..2,1..2);A := Matrix(2);B := Matrix(2,3);C := Matrix(1..2,1..3,5);E := Matrix([[1,2,3],[4,5,6]]);F := <<1,2,3>|<4,5,6>>;F[2,2];G := Matrix([1,2,3]);G[2];C+2*E;C*~E;C/~E;F.E;E.C;JSFHJSFHBasic plottingMaple can be used to easily create two and three dimensional graphs.The command plot is used to create a two-dimensional plot. The first argument is the expression to be plotted and the second argument denotes the dependent variable and its range. The plot can have some additional options such as:vertical range: if this is specified then it must be the third argument. Unlike the horizontal range, when specifying the vertical range, you don\342\200\231t specify a variable.axes: Specifies the type of axes to be drawn on the plot. axes can be set to the following: boxed, frame, none or normal, which can be specified in either upper or lower case letters.color: Specifies the color of the lines. All lines in the plot will change to the color specified.labels: : Specifies the labels of the axes. By default, Maple will put the dependant variable (which from the specification of the horizontal range) on the horizontal axis, and leave the vertical axis with no label. To change this, you need to specify a string each for the horizontal and vertical axes. labeldirections: Specifies the directions of the axes labels. By default all labels will be written horizontally on the graphs.linestyle: Specifies the style of the lines. linestyle must be set equal to either be 1, 2, 3 or 4, or one of the following names: SOLID, DOT, DASH, or DASHDOT.thickness: Specifies the thickness of the lines, default is 0.numpoints: Specifies the minimum number of points used to generate the plot.<Text-field style="Heading 1" layout="Heading 1"></Text-field>plot(sin(x),x=0..2*Pi);plot(sin(x),x=0..2*Pi,-1.5..1.5,color=blue,thickness=5,linestyle=3,labels=["x","sin(x)"],labeldirections=[horizontal,vertical],axes=normal,numpoints=500);JSFHIf you want to plot points, you need to order these points in a list.<Text-field style="Heading 1" layout="Heading 1"></Text-field>L := [[0,0],[1,1],[1,0.5]];
plot(L,color=green,thickness=3,linestyle=4);plot([op(L),L[1]],color=green,thickness=3,linestyle=4,filled=true);JSFHParametric functions can also be plotted<Text-field style="Heading 1" layout="Heading 1"></Text-field>plot([sin(t),cos(t),t=0..2*Pi],-1.3..1.3,-1.3..1.3);JSFHYou can also plot multiple functions on the same graph.<Text-field style="Heading 1" layout="Heading 1"></Text-field>plot([sin(x),x^2/20],x=0..2*Pi,thickness=[5,2],color=[green,blue],linestyle=[3,1]);JSFH3D plot are similar to 2D plots, however now we use the command plot3d for which we need to specify both dependent variables instead of one. <Text-field style="Heading 1" layout="Heading 1"></Text-field>plot3d(cos(x*y),x=-Pi..Pi,y=-Pi..Pi);plot3d(cos(x*y),x=-Pi..Pi,y=-Pi..Pi,axes=none,color=blue);JSFHSimplifying and manipulating expressionsThere are many possible ways to simplify or manipulate expressions in Maple. However, some of the simplifications are done automatically.<Text-field style="Heading 1" layout="Heading 1"></Text-field>unassign('x');x+0;x+x;x-x;x*1;x*x;x/x;x^0;x^1;infinity/infinity;0/0;JSFHExpressions are factorized using the factor command.<Text-field style="Heading 1" layout="Heading 1"></Text-field>factor(x^2-4);rat_fun := (x^2-4)/(x^2+2*x+1):
factor(rat_fun);factor(numer(rat_fun))/denom(rat_fun);JSFHThe opposite, namely expanding expressions, can also be done, by using the expand command.<Text-field style="Heading 1" layout="Heading 1"></Text-field>expand((x-2)*(x+2));expand(((x-2)*(x+2))/((x+1)^2));normal(((x-2)*(x+2))/((x+1)^2),expanded);expand(sin(x+y));JSFHYou can also simplify expressions using well-kwown simplification rules using the simplify command. This can be applied to function calls, square roots, radicals, powers, etc...<Text-field style="Heading 1" layout="Heading 1"></Text-field>4^(1/2)+3;simplify(4^(1/2)+3);exp(a+ln(b*exp(c)));simplify(exp(a+ln(b*exp(c))));JSFHTo combine terms in sums, product and powers, the combine command is needed.<Text-field style="Heading 1" layout="Heading 1"></Text-field>simplify(sin(x)*cos(y)+cos(x)*sin(y));combine(sin(x)*cos(y)+cos(x)*sin(y));fun := 4*sin(x)^3 + exp(x)*exp(y);
combine(fun);combine(fun,exp);JSFHTo collect the coefficients of a variable or function in an expression, the command collect can be used.<Text-field style="Heading 1" layout="Heading 1"></Text-field>g := 3*(x-2)+x*(2-3*x^2);
collect(g,x);f := a*ln(x)-ln(x)*x-x;
collect(f,ln(x)); p := x*y+a*x*y+y*x^2-a*y*x^2+x+a*x;
collect(p,y);collect(p,[x,y]);collect(p,[y,x]);collect(p,[x,y],distributed);JSFHWhen working with polynomials, you can also obtain the coefficients by using the commands coeff and coeffs.<Text-field style="Heading 1" layout="Heading 1"></Text-field>p := 4*x^2+3*y^2-5*x+3;coeff(p,x,2);coeff(p,x^2);s := 3*v^2*y^2+2*v*y^3;coeffs(s,v);coeffs(s,y,'yt');
yt;JSFHFinally, you can also select or remove certain terms from an expression.<Text-field style="Heading 1" layout="Heading 1"></Text-field>f := 2*exp(a*x)*sin(x)*ln(y)*y;select(has,f,x);remove(has,f,x);remove(has,f,[x,ln(y)]);selectremove(has,f,x);JSFHSolving equationsTo solve algebraic equations, we can use the solve or fsolve command.<Text-field style="Heading 1" layout="Heading 1"></Text-field>eqn := f=5*a;solve(eqn,a);eqn := x^4-5*x^2+6*x = 2;sols := solve(eqn,x);
sols[2];evalf(sols);fsolve(eqn,x);p := x^2+1;solve(p,x);fsolve(p,x);fsolve(p,x,complex);fsolve(sin(x)=1,x);fsolve(sin(x)=1,x=-6..0);eqn1 := 4*x-5*y = 3;
eqn2 := x+7*y = 0;solve({eqn1,eqn2},{x,y});solve({eqn1,eqn2},[y,x]);JSFHIf statements and for loopsWhen writing programs, it is common to want to test to see if an expression is true, and then execute some other statements depending on the value of the first expression. The relational operators are <, >, <=, >=, =, <> .<Text-field style="Heading 1" layout="Heading 1"></Text-field>a := 3;
b := 2;if a > b then
c := a-b
else
c := b-a
end if;if c < b and a < b then
b-a;
b-c;
elif c < b and a > b then
a-b;
b-c;
elif c > b and a < b then
b-a;
c-b;
else
a-b;
c-b;
end if;JSFHTo repeat an expression, we use a for loop.<Text-field style="Heading 1" layout="Heading 1"></Text-field>summ := 0;
for i from 1 by 2 to 10 do
summ := summ + i;
end do;for i from 1 by 2 to 100 do
for j in [1,2,3,4] do
i*j
end do;
end do;JSFHFunctions and proceduresThe simplest way to create a function is to use the -> operator.<Text-field style="Heading 1" layout="Heading 1"></Text-field>f := x-> 3*x+5;f(2);g := (x,y) -> sin(x) + y; g(Pi/2,3);JSFHMore advanced functions can be created using the proc command. These functions can have multiple input arguments but returns only one value. To return more than one value, you can use module.<Text-field style="Heading 1" layout="Heading 1"></Text-field>fun := proc(a,x,b,y)
description "linear combination of its arguments: a*x + b*y";
local lincom;
lincom := a*x+b*y;
return lincom
end proc;fun(1,2,3,4);JSFHUseful packagesSometimes it is useful to include a package in Maple which contains some additional commands. This is done through the with command. <Text-field style="Heading 1" layout="Heading 1"></Text-field>with(plots);with(plots,animate);plots[animate]( plot, [sin(A*x), x=-Pi..Pi, thickness=5], A=1..5 );JSFHThe two most useful packages are:plots: contains over fifty commands that can be used to plot various Maple expressions and data structuresLinearAlgebra: over one hundred commands to manipulate Vector\342\200\231s and Matrices. Examples: tranpose, eigenvalues, ...