Introduction
Introduction to Maple
At the beginging of every session, it is a good idea to use the restart command. The restart command will cause the Maple kernel to clear its internal memory so that it acts as if you had just started Maple.
> restart;
adding 3, 5 and 5
> 3 + 4 + 5;
Expand the expression and name the expanded results e1
> e1 := expand( x*(x+1)*(x1) );
Factor the previous result
> factor( % );
Compute the floating value of
> evalf( sqrt(2) );
Solve the equation (previously called e1) for x
> solve(e1=0, x);
Differentiate with respect to x
> diff(cos(x)+ x*ln(x)3*x^2,x);
Integrate with respect to x
> int(x*exp(x), x);
To obtain help, use ? followed by a command name
> ?plot;
See Also: help , maple , index , index[function]
assign
Function: assign  perform assignments
Calling Sequence:
assign(a, b)
assign(a = b)
assign(t)
Parameters:
a 
a name
b 
any expression
t 
a list or set of equations
One use of this function is to apply it to a set of equations returned by the solve function when it is desired to assign the solution values to the variables.
Solve the linear system for x and y and place the results in a set called s
> s := solve( {x+y=1, 2*x+y=3}, {x,y} );
Now if we type x; or y; Maple does not return the values of x or y. The reason is that the values are not assigned to x and y
> x;
> y;
With the assign command the values are assgind to x and y. So x will have the value 2 and y the value 1
> assign(s);
> x;
> y;
To unassign the values use the command unassign. Note that the variable must be placed between quotation marks.
> unassign('x','y');
Now, x and y will no longer have the values of 2 and 1
> x,y;
diff and Diff
Function: diff or Diff  Differentiation or Partial Differentiation
Calling Sequence:
diff(expr, x1, x2, ..., xn)
Diff(expr, x1, x2, ..., xn)
diff(expr, [x1, x2, ..., xn])
Diff(expr, [x1, x2, ..., xn])
Parameters:
expr 
an algebraic expression
x1, x2, ..., xn  variables with respect to which differentiation is performed
Examples:
> diff(sin(x),x);
> diff(sin(x),y);
The sequence operator $ is useful for forming higherorder derivatives. diff(f(x),x$4), for example, is equivalent to diff(f(x),x,x,x,x)
> diff(sin(x),x,x,x);
> diff(sin(x),x$3);
and diff(g(x,y),x$2,y$3) is equivalent to diff(g(x,y),x,x,y,y,y)
> diff(g(x,y),x,x,y,y,y);
> diff(g(x,y),x$2,y$3);
>
> diff(y^2*x^4,x,x,y,y);
> diff(y^2*x^4,x$2,y$2);
> diff(tan(x),x);
The capitalized function name Diff is the inert diff function, which simply returns unevaluated.
> Diff(tan(x),x);
> Diff(tan(x),x) = diff(tan(x),x);
Since f(x) and f(x,y) are not defined, no evaluation is returned
>
diff(f(x),x);
diff(f(x,y),x,y);
The diff command assumes that partial derivatives commute, that is,
> diff(f(x,y),x,y)  diff(f(x,y),y,x);
These two forms are equivalent:
Variables with respect to which differentiation is performed are given as a list (not inclosed in brackets [ ] )
> diff(g(x,y,z),x,z,z);
Or, they may be given as a list
> diff(g(x,y,z),[x,z,z]);
dsolve
dsolve  Solve ordinary differential equations (ODEs)
dsolve(ODE)
dsolve(ODE, y(x), extra_args)
dsolve({ODE, ICs}, y(x), extra_args)
dsolve({sysODE, ICs}, {funcs}, extra_args)
Parameters:
ODE  an ordinary differential equation
y(x)  any indeterminate function of one variable
ICs  initial conditions
{sysODE}  a set with a system of ODEs
{funcs}  a set with indeterminate functions
extra_args  optional, depends on the type of problem being solved (see below)
* Herein {x, y(x)} represent any pair of independent and dependent variables.
> infolevel[dsolve]:= 0;
INPUT AND OUTPUT
THE OPTIONAL ARGUMENTS
.
odeadvisor , dsolve,algorithms , dsolve,education , dsolve,ICs , dsolve,inttrans , dsolve,formal_series , dsolve,Lie , dsolve,linear , dsolve,numeric ; dsolve,piecewise , dsolve,series , dsolve,system , odeadvisor,types , and the Maple packages for differential equations DEtools , PDEtools
>
>
> unassign('y','x');
> de:=diff(y(x),x$2)y(x)=sin(x)*x,y(x);
> dsolve(diff(y(x),x$2)y(x)=sin(x)*x,y(x));
Solve an initial value problem
> dsolve({diff(v(t),t)+2*t=0, v(1)=5}, v(t));
> dsolve(diff(y(x),x)  alpha*y(x) = 0, y(x), explicit=true);
> de1 := diff(y(t),t$2) + 5*diff(y(t),t) + 6*y(t) = 0;
> dsolve({de1, y(0)=0, D(y)(0)=1}, y(t),method=laplace);
> dsolve(diff(y(x),x$2)+2*diff(y(x),x)+6*y(x)=x,y(x),output=basis);
>
sys := diff(y(x),x)=z(x)y(x)x, diff(z(x),x)=y(x);
fcns := {y(x), z(x)};
> F := dsolve({sys,y(0)=0,z(0)=1}, fcns);
First order ODEs (see ? odeadvisor ).
> ode1 := diff(y(x),x)y(x)^2+y(x)*sin(x)cos(x);
> ans1 := dsolve(ode1);
> with(DEtools): odeadvisor(ode1);
ODE of high degree in dy/dx.
A linear ODE
> ode_L := sin(x)*diff(y(x),x)cos(x)*y(x)=0;
One can indicate to dsolve to use a specific sequence of 'methods' to tackle the ODE. In this example the method for 'linear' ODEs is indicated; in addition the optional argument 'useInt' makes dsolve not evaluate the integral appearing in the answer
> dsolve(ode_L, useInt);
To see the answer before evaluating integrals is useful to understand how the answer was obtained; integrals can be evaluated afterwards using value
> value(%);
Or you can use the dsolve command without specifying the useInt option
> dsolve(ode_L);
This particular linear ODE is also separable
> dsolve(ode_L, [separable], useInt);
> value(%);
As a general alternative, one can look for an integrating factor (see ? DEtools,intfactor )
> mu := intfactor(ode_L);
Integrating factors turn ODEs exact; to indicate to dsolve to use the scheme for exact ODEs:
> dsolve( mu*ode_L, [exact], useInt);
> dsolve( mu*ode_L);
> value(%%);
A second order linear homogeneous ODE
>
ode4 := diff(y(x), x$2)  x*diff(y(x),x)
y(x)=0;
> dsolve(ode4);
A nonlinear second order example
>
ode5 := diff(y(x),x,x) =
1/y(x)^2;
> ans5 := dsolve(ode5);
Error, invalid subscript selector
A nonlinear high order example solved using symmetry methods:
>
ode6 := diff(diff(y(x),x),x)*diff(y(x),x)*y(x)*x^6
2*diff(y(x),x)^3*x^6+2*diff(y(x),x)^2*y(x)*x^5+y(x)^5;
> dsolve(ode6);
>
See Also: diff , D , convert[diff] , convert[D] , DESol , rsolve , series , dsolve[numeric] , dsolve[rkf45] , dsolve[dverk78] , dsolve[classical] , dsolve[gear] , dsolve[mgear] , dsolve[lsode] , DEtools , plots[odeplot] , inttrans , pdesolve
expand
Function: expand  Expand an Expression
> expand((x+1)*(x+2));
> expand((x+1)*(x+3)/(x+2));
> expand(sin(x+y));
> expand(cos(2*x));
> expand(exp(a+ln(b)));
> expand(ln(x/(1x)^2));
> expand((x+1)*(y+z), x+1);
>
See Also: expandoff , expandon , collect , combine , factor , frontend , normal , sort , Expand
function
Help For: Functional operators
Define the function f(x) = 3 x + 5
> f := x > 3*x + 5;
> f(2);
Define a multivariate function g(x,y) = sin(x) cos(x) + x y
> g := (x,y) > sin(x)*cos(y) + x*y;
> g(Pi/2, Pi);
Define a vector function
> h := x > (2*x, x^3);
> h(3);
> h(x);
> k:= x > linalg[matrix](2,1,[2*x,x^3]);
> k(3);
See Also: unapply , @ , @@ , D , operators[D] , operators[example]
int
Function: int or Int  Definite and Indefinite Integration
Calling Sequences:
int(expr, x) Int(expr, x)
int(expr, x=a..b, ...) Int(expr, x=a..b, ...)
Parameters:
f 
an algebraic expression or a procedure, the integrand
expr

a variable with respect to integration is performed
a, b 
the limits of integration for definite integrals
... 
options
> int( sin(x), x );
> Int( sin(x), x );
> int( sin(x), x=0..Pi );
> Int( sin(x), x=0..Pi );
> int( x/(x^31), x );
> int( exp(x^2), x );
Maple is unable to evaluate the following integral
> int( exp(x^2)*ln(x), x );
See Also: diff , evalf , series , limit , iscont , student[Int] , fourier , laplace , mellin , int[numerical]
map
Function: map  apply a procedure to each operand of an expression
Function: map2  apply a procedure with a specified first argument to each operand of an expression
Calling Sequence:
map(fcn, expr, arg2, ..., argn)
map2(fcn, arg1, expr, arg3, ..., argn)
Parameters:
fcn 
a procedure or a name
expr 
any expression
argi 
(optional) further arguments to fcn
> unassign('f','y');
> map(f, x + y*z);
> map(f, y*z);
> map(f, {a,b,c});
> map(x > x^2, x + y);
> map(proc(x,y) x^2+y end, [1,2,3,4], 2);
> map2(f, g, {a,b,c});
See Also: op , proc , operators[functional] , select
matrix
Help For: matrices
> linalg[matrix](2,3,[x,y,z,a,b,c]);
> array(1..2,1..2,[[1,2],[3,4]]);
> type(%,matrix);
>
array(0..1,0..1,[[a,b],[c,d]]):
type(%,matrix);
> A:=linalg[matrix](2,2,[sin(x), x^2+x+3, exp(x), cos(x^2)]);
> map(diff, A, x);
See Also: linalg[matrix] , linalg , array , vector , evalm , print , map , type
op
Function: op  extract operands from an expression
Function: nops  the number of operands of an expression
Calling Sequence:
op(i,expr) op(i..j,expr) op(expr) op(list,expr)
nops(expr)
Parameters:
i,j 
integers marking positions of operands
expr 
any expression
list 
a list of integers marking positions of operands at increasing nesting levels of an expression
Define a list of three elements (operands)
> u := [1,4,9];
> nops(u);
> op(2,u);
> op(2..3,u);
> op(u);
> op(0,u);
> [op(u),16];
> v := f(x,y,z);
> nops(v);
> op(0,v);
> op(2,v);
> op(4,v);
Error, improper op or subscript selector
> op(v);
> w := f(g(a,b),h(c,d));
Retrun the 2nd operand of the first operand of w
> op(1,op(2,w));
The same as above but clearer
> op([2,1],w);
See Also: subsop , applyop , map , type
restart
start over, (almost) as if Maple were restarted
> a := 2;
Load the differential equation tools package
>
with(DEtools):
Define a 2nd order DE in stanadard form de:=diff(y(x),x$2)+p(x)*diff(y(x),x)+q(x)*y(x)=0;
Use the reduceOrder command supplied with the DEtools package (given a solution y[1](x), find another solution y[2](x)
> y[2](x):=reduceOrder(de,y(x),y[1](x));
Restart Maple
> restart;
The value of a is no longer known
> a;
The command reduceOrder is no longer knows
> y[2](x):=reduceOrder(de,y(x),y[1](x));
sets and lists
Help For: Sets and lists
Parameters:
es 
an expression sequence
> {x,y,y};
> {y,x,y};
> [x,y,y];
> [y,x,y];
> L := [seq(x[i],i=1..4)];
> L[2];
> L := [op(L),x[5]];
> L[3..2];
> L := subsop(2=NULL,L);
See Also: selection , op , nops , union , intersect , minus , member , convert , seq
simplify
Function: simplify  Apply Simplification Rules to an Expression
Calling Sequence:
simplify(expr)
simplify(expr, n1, n2, ...)
simplify(expr, assume=prop)
Parameters:
expr 
any expression
n1, n2,... 
(optional) names or sets or lists
prop 
any property (optional)
> expr1:=4^(1/2)+3;
> simplify(expr1);
> expr2:=exp(a+ln(b*exp(c)));
> simplify(expr2);
>
expr3:=sin(x)^2+cos(x)^2;
simplify(expr3);
>
e := cos(x)^5 + sin(x)^4 + 2*cos(x)^2  2*sin(x)^2  cos(2*x);
simplify(e);
>
f := 1/3*x^5*y + x^4*y^2 + 1/3*x*y^3 + 1;
simplify(f, {x^3 = x*y, y^2 = x+1});
> g:=sqrt(x^2);
> simplify(g);
> simplify(g,assume=real);
> simplify(g,assume=positive);
See Also: collect , combine , convert , expand , factor , normal , radsimp , assume
solve
Function: solve  Solve Equations
Calling Sequence:
solve(eqn, var)
solve(eqns, vars)
Parameters:
eqn 
an equation or inequality
eqns 
a set of equations or inequalities (equations or inequalities enclosed between braces {})
var 
(optional) a name (unknown to solve for)
vars 
(optional) a set of names (unknowns to solve for) (unkowns enclosed between braces {})
floats functions identity ineqs linear
radical scalar series system
> restart;
Solve for a
> solve( f=m*a, a );
Solve eq for x
>
eq := x^45*x^2+6*x=2;
solve(eq,x);
Solve eq for x and put the answers in a list (brackets). This way we can refere to the solutions as elements of the list
> sols := [solve(eq,x)];
Element i in the list is refered to as sols[i].
> sols[1];sols[3];
Use evalf to converst the answers to floating points
> evalf(sols);
> eq;
Solve eq for x and put the answers in a set (braces). We can then refer to the elemenst using subscripts.
Note that the repeated root was not listed twice as was the case in putting the answers in a list (see above)
>
sols := {solve(eq,x)};
sols[1];sols[3];
Check the first answer by substituting it in the equation
> subs( x=sols[1], eq );
> simplify(%);
Equations are provided in a set, no set of unknowns is provided (hence Maple assumes that we are solving for the variables in the equations):
>
eqns := {u+v+w=1, 3*u+v=3, u2*vw=0};
Manipulating Solutions solve for u,v,w
> sols := solve( eqns );
check solutions
> subs( sols, eqns );
pick off one solution
> subs( sols, u );
assign all solutions
>
assign( sols );
u;w;
Other examples
> solve( cos(x)+y = 9, x );
> solve( x^2+x>0, x );
Solve a system of equations
> solve( {x^2*y^2=0, xy=1} );
> solve( {x^2*y^2=0, xy=1, x<>0} );
See Also: RootOf , allvalues , dsolve , fsolve , isolve , msolve , rsolve , assign , invfunc , isolate , match , linalg[linsolve] , simplex , grobner , solve[subtopic] where subtopic is one of: floats , functions , identity , ineqs , linear , radical , scalar , series , system
unapply
Function: unapply  Returns an Operator from an Expression and Arguments
Calling Sequence:
unapply(expr,x,y,..)
Parameters:
expr 
any expression
x,y,.. 
variable names
> p := x^2 + sin(x) + 1;
> f := unapply(p,x);
> f(Pi/6);
> q := x^2 + y^3 + 1;
> f := unapply(q,x);
> f(2);
> g := unapply(q,x,y);
> g(2,3);
See Also: operators[functional] , operators[example] , operators[D]
with
Function: with  loads a library package such as DEtools, linalg, etc
Define a 2 x 2 matrix
> a:=matrix(2,2,[1,2,3,4]);
The inverse of the matrix in not computed because the inverse command resides in the package linalg which has not been loaded yet
> inverse(a);
Load the linear algebra package. The commands that are available in the package are listed (if you do not want to see the list of availabe commnads terminate the with command with ' : ' instead of ' ; ')
> with(linalg):
Warning, the protected names norm and trace have been redefined and unprotected
Now the inverse command is availabe and the inverse of a is computed
> inverse(a);
See Also: index[package] , readlib , libname , table , indexfcn
wronskian
Function: linalg[wronskian]  wronskian matrix of a vector of functions
Calling Sequence:
wronskian(f, v)
Parameters:
f 
a vector or list of expressions
v 
a variable
> with(linalg):
> A := vector([exp(x),cosh(x),sinh(x)]);
> Wr := wronskian(A,x);
> det(Wr);