You are on page 1of 2

Maple commands

General
restart: unassign all variables
unassign: unassign a certain variable
> unassign(y)
evalf: convert an exact number into a decimal floating point approximation
> evalf(62/11)
> evalf(Pi,50)
seq: generate a sequence of objects
> seq(x^a,a=1..7,2)
unapply: create a function out of an expression
> f:=unapply(x^3,x)
assign: make an assignment out of an equation
> assign(p=x^3); p
subs: substitute a system of equations into an expression
> subs({x=1,y=2},x^2+y^3+z^4)

Calculus
D: differentiate a function
> f:=x->x^3; D(f)
diff: differentiate an expression
> diff(x^3,x)
> diff(x^2*y,x,y)
int: integrate an expression
> int(x^3,x)
> int(x^3,x=2..3)

Solving
solve: solve an equation or a system of equations
> solve(x^2=x+1,x)
> solve({x+y=1,x-y=2},{x,y})
fsolve: return a floating point approximation of the solutions
> fsolve(x^2=x+1,x)
> Digits:=50; fsolve(x^2=x+1,x)
dsolve: solve a differential equation, a system of differential equations, or an initial value problem
> diffeq:=diff(x(t),t)=-x(t)
> dsolve(diffeq,x(t))
> dsolve({diffeq,x(0)=3},x(t))
> sys:={diff(x(t),t)=y(t),diff(y(t),t)=-x(t)}
> dsolve(sys,[x(t),y(t)])
> dsolve(sys union {x(0)=1,y(0)=0},[x(t),y(t)])
dsolve: find approximate solutions to an initial value problem
> IVP:={diff(x(t),t)=cos(t)+sin(x(t)),x(0)=1}
> sersol:=dsolve(IVP,x(t),type=series)
> numsol:=dsolve(IVP,x(t),type=numeric)
> IVPsys:={diff(x(t),t)=x(t)*(1-y(t)),diff(y(t),t)=y(t)*(x(t)-1),x(0)=2,y(0)=1}
> numsolsys:=dsolve(IVPsys,[x(t),y(t)],type=numeric)

1
convert: convert a power series into a polynomial
> sersol:=dsolve(IVP,x(t),type=series); assign(sersol)
> pol:=convert(x(t),polynom)

Plotting
plot: graph a function or a list of functions
> plot(x^3)
> plot(x^3,x=-2..2)
> plot(x^3,x=-2..2,y=-4..4)
> plot([x,x^2,x^3],x=0..1)
plot: parametric plot of a curve
> plot([cos(t),sin(t),t=0..2*Pi])
plot3d: graph a function of two variables
> plot3d(sin(x)*exp(cos(y)),x=-3..3,y=-3..3,axes=boxed)
animate: animate a family of curves
> with(plots): animate(exp(-a*x)*sin(a*x),x=0..2*Pi,a=1..5)
odeplot: plot a numerical solution to an initial value problem
> with(plots): odeplot(numsol,[t,x(t)],t=0..1)
> odeplot(numsolsys,[[t,x(t)],[t,y(t)]],t=0..10)
dfieldplot: plot the direction field of a diff. equation or an autonomous system of two diff. equations
DEplot: plot both the direction field and some particular solutions
> with(DEtools):
> diffeq:=diff(x(t),t)=-x(t)
> dfieldplot(diffeq,x(t),t=-2..2,x=-2..2)
> DEplot(diffeq,x(t),t=-2..2,[[x(0)=-1],[x(0)=1]],x=-2..2)
> sys:={diff(x(t),t)=y(t),diff(y(t),t)=-x(t)}
> dfieldplot(sys,[x(t),y(t)],t=0..1,x=-2..2,y=-2..2)
> DEplot(sys,[x(t),y(t)],t=-5..5,[[x(0)=1,y(0)=0]],x=-2..2,y=-2..2)

Linear algebra
> with(linalg):
matrix: define a matrix
> A:=matrix([[1,2],[3,4]])
> B:=matrix(2,2,[1,2,3,4])
evalm: evaluate an expression involving matrices
> evalm(A+B)
&*: matrix multiplication or matrix-vector multiplication
> evalm(A&*B)
vector: define a vector
> v:=vector([3,4]); evalm(A&*v)
det: compute the determinant
trace: compute the sum of the diagonal elements
inverse: compute the inverse matrix
> det(A); trace(A); inverse(A)
eigenvals: compute eigenvalues
eigenvects: compute eigenvalues and eigenvectors; returns a sequence of triples [i , mi , {v1,i , . . . , vni ,i }],
where i is the eigenvalue, mi the algebraic multiplicity, and {v1,i , . . . , vni ,i } a basis of the eigenspace
> eigenvals(A); eigenvects(A)

You might also like