Maple Command Summary
Notation
This section describes the syntax of this document. This does not necessarily describe the syntax of Maple!
- ...
Indicates many more optional arguments. Usually separated by commas.
- |variable|
Anything enclosed in |'s is a variable. That is, it stands for an object which is to be described. For example, in the expression
|command| stands for any maple command. When prefixed by a ?, maple will give you help on |command|.
- |express|
|express| means an arbitrary maple expression. For example, 3*x+2 is an expression. sin(x)*simplify(cos(x)^2+2) is also an expression.
- |range|
|range| stands for a function range in maple. A function range is a number, following by two .'s followed by another number. Just as in the plot command. For example: plot(x^2,x=-2..2) Here, -2..2 is the range.
Maple Structures
There are five basic structures which we will learn about during the course: expressions, sequences, lists, sets, and functions. Once you understand the ideas and use of these objects, maple becomes a powerful tool.
- Expressions
Basically anything you type into maple is an expression. Numbers, variables, and combinations of these and operations maple up an expression. If its not an expression its either a function or a sequence/list/set of expressions or functions.
- Sequences
Sequences are a series of maple expressions separated by commas. For example:
Sequences can be made into lists or sets simply by enclosing them in [] or {} respectively.
- Lists
Lists are sequences enclosed in []. Lists preserve order. That is, if you type [2,1,-2,5,18] into maple, maple will give the list in the same order as output.
- Sets
Sets are sequences enclosed in {}. Sets do NOT preserve order. That is, if you type {2,1,0,4} into maple, you may not necessarily get back {2,1,0,4} as output. You must be careful of sets. Many of maple's functions return sets and their output cannot be trusted to be in the same order (when array indexing for example).
- Functions
Functions are "arrow functions" in maple. To define a function f which computes the x*sin(x) for any value of x, you do: f := x -> x*sin(x);. To turn a function into an expression, simply take the function at x -- f(x). To turn an expression into a function, you must use the unapply command.
General Notes
This document contains a list of maple commands learned to date in
21-125, Calculus Maple Lab. It is by no means a complete list. For help on
a particular command, type
Commands
- plot(|function|,|var|=|range|,|var2|=|range2|,...)
Plots |function| on the horizontal range |range| and the vertical range |range2|. |function| must be a function of |var| and |var2|. To plot multiple functions, enclose in {} or []. Ranges can also be ommited. See the help file for complete details.
Example: plot(x^2+2*x+4,x=-10..10);
Example: plot({x^2+2,2*x+4,5},x=-10..10);
- "
refers to the last command. Likewise "" refers to the second last and so forth on.
Example: f:= (x+2)^2; plot(",x=-10..10);
- simplify(|express|,|mode|)
Applies simplification techniques to the maple expression, |express|. |mode| is an optional argument specifying a type of simplification. Some basic modes are trig, radical, ln, and symbolic.
Example: simplify(cos(2*x)+sin(x)^2);
- assume(|assump|) or assume(|var|,|prop|)
Asks maple to assume |assump| which is a relational expression (y>0). Alternatively, |var| is any variable and |prop| is a property or type. |prop| can be integer, rational, etc..
Example: assume(x>0);
Example: assume(x,integer);
- expand(|express|)
Multiplies out an expression, |express|. That is, writes an expression in its longest form. Sometimes you need to go backwards before you can go forwards in simplification.
Example: expand((x^2+5*x+4)^10);
- combine(|express|,|type|)
Simplifies by attempting to put together similar expressions, |express|. |type| can be ln,trig,radical,etc.
Example: combine(ln(a)-ln(b),ln);
- factor(|express|)
Reverse of expand(). Factors an expression, |express|.
- solve(|express|=0,|var|)
Finds the roots of an experssion given by |express|. Maple assumes you mean |express|=0 unles you tell it otherwise. |var| is the variable to solve for (in case it is not obvious). For instance, if you have 5 variables but want a solution to three variables in terms of the other two, you will need to specify which variables. Both a set of equations and a set of variables can be used instead of just one to solve for a system of equations.
Example: solve(x^3-3*x+1=0,x);
Example: solve({x+y=5,2*x+3*y=10},{x,y})
- |var|[|i|]
Returns the |i|th element of a sequence, list or set given by |var|. Remember that references are 1 relative! a[2] is the second item in the sequence, not the third.
Example: z := {a,b,c,d}; z[4];
- evalf(|value|)
Converts |value| which may be a long mathematical expression into a floating point number. An optional argument can tell evalf how many decimal places to evaluate to.
- fsolve(|express|=0,|var|)
Similar to solve. Finds the REAL roots of an expression and returns their decimal approximation. Solves for the variable |var|.
Example: fsolve(x^5+x^2+1=0,x);
- Digits := |precision|
Increases the accuracy of maple's calculations. |precision| is how many numbers (not decimals) to output.
- limit(|express|,|var|=|value|,|direction|)
Takes the mathematical limit of an expression, |express|. The limit is taken when |var| = |value|. Limits can be taken to the left or right by the optional argument, |direction|.
Example: limit(sin(x),x=infinity);
Example: limit(abs(x)/x,x=0,left);
- diff(|express|,|var|,...)
Takes the mathematical derivative of the expression, |express| with respect to |var|. diff() can differentiate multiple times by adding more variables to the end, separated by commas.
Example: diff(x^4+2*x,x,x);
- |express|$|num|
Makes |num| copies of |express| and expands them into a sequence. i$4 = i,i,i,i.
Example: diff(x^4+2*x,x$4);
- int(|express|,|var|=|range|)
Integrates |express| ANALYTICALLY . Integrates by |var| over |range| if |range| is given. Otherwise, int() will give the indefinite integral if it can.
Example: int(x^2,x=-2..2);
- Int(|express|,|var|=|range|)
The arguments are the same as int(). However, Int() returns the integral unevaluated. You can then evalf() the returned integral to obtain a NUMERICAL integration.
Example: evalf(Int(x^2,x=-2..2));
- subs(|var|=|express1|,|express2|)
Evalutes |express2| when |var|=|express1|. Usually |express1| is a value, but it can be another variable or expression. Subs does not assign |var|=|expres1| in |express2|. If you re-execute |express2|, it will still be in its original form.
Example: subs(x=0,x^2+2*x+4);
- rem(|poly|,|div|,|var|,'|quot|')
Finds the remainder of |poly|/|div| with respect to |var|. The quotient is stored in the |quot| variable if given.
Example: rem(x^6+17*x^4+11*x,x^4-7,x,'q');
- convert(|express|,|form|,|var|)
Converts |express| into a different form given by |form|. See help on convert for different forms, such as parfrac.
Example: convert(x^4/(x^2+2*x+1),parfrac,x);
Example: convert([2,3,4,5,6],`+`);
- seq(|express|,|var|=|range|)
Creates a Sequence by substituting each value of |var| in the given limits into |express|.
Example: seq(i^2,i=0..20);
- map(|function|,|list|)
Applies a maple command, |function| to a List , |list|.
Example: map(sqrt,[4,9,16,25]);
- sum(|express|,|var|=|range|)
Sums the sequence given by substitutions of |var| into |express| over the |range|. Equivalent to using sequence and convert(,`+`).
Example: sum(i^2,i=0..20);
- product(|express|,|var|=|range|)
Multiplies the sequence given by substitutions of |var| into |express| over the |range|. Equivalent to using sequence and convert(,`*`).
Example: product(1/n,n=1..20);
- series(|express|,|var|=|val|,|order|)
Creates a series expansion of |express| in terms of variable |var| around |val|. =|val| is optional. If it is not given, the Maclauren series is given (the series at |var|=0). |order| is how many terms of the series to return (since it is infinite).
Example: series(exp(x),x=4,25);
- f := |var| -> |express|
Sets the variable f to be an "arrow function" of the variable |var| which computes |express| at this variable. That is, you can print the value of the function at a value p by doing f(p).
Example: f := x ->sin(x)*(x^2-2*x+4); f(z);
- unapply(|express|,|var|)
Turns an expression, |express|, into a function of the variable |var|.
Example: unapply(x^2+2*x+4,x);
- if |bol-express| then |express| else |express| fi
If statement. Evaluates |bol-express| which must be an expression that evalutes to TRUE or FALSE. If |bol-express| is true, maple executes the first |express| and returns its value. If false, maple returns the value from the second |express|. fi is called a delimiter. It simply indicates the end of the if statement. |express| can be any maple expression, including more powerful constructs like another if statement or a for loop.
Example: x -> if x< 0 then -1 else 1 fi;
- evalb(|express| |operation| |express|)
Evalutes a BOOLEAN expression (one that evalutes to true or false). |operation| is one of the typical mathematical operators: <,>,>=,<=,=. Evalb returns true or false.
Example: evalb(a+b+c*x+d=d+b+c*x+a);
Linear Algebra
- with(linalg)
Loads the linear algebra functions of maple into memory. You MUST execute this command EVERY time you load maple or a new worksheet to use the linear algebra functions.
- matrix(|row|,|col|,|init|)
Creates a matrix of size |row|x|col|; That is a matrix wil |col| columns and |row| rows. |init| is an optional LIST of items to initialize the matrix with. If |init| is not given, a generic matrix is generated. |init| items are filled into the matrix by row from left to right.
Example: matrix(2,2,[1,-2,2,4]);
- scalarmul(|m|,|value|)
Multiply each item in the matrix |m| by |value|. Value can be any number you wish.
Example: scalarmul(matrix(3,2,[1,2,3,4,5,6]),2);
- add(|m1|,|m2|)
Add the matrices |m1| and |m2| and give the result. |m1| and |m2| must have the same dimensions (same number of rows and columns).
Example: add(matrix(1,2,[1,2]),matrix(1,2,[2,4]));
- subtract(|m1|,|m2|)
Subtract matrix |m2| from |m1 and give the result. Again the number of rows and columns must be the same for both matrices.
Example: subtract(matrix(1,2,[1,2]),matrix(1,2,[2,4]));
- multiply(|m1|,|m2|)
Multiply matrices |m1| and |m2| together and return the result. |m1| and |m2| must have compatible dimensions (m1 rows = m2 cols). Note: multiply(|m1|,|m2|) does not necessarily equal multiply(|m2|,|m1|).
Example: multiply(matrix(1,3,[1,1,2,2,3,3]),matrix(3,1,[4,3,2]));
- randmatrix(|row|,|col|)
Creates a matrix with random elements of size |row|x|col|. Good for testing hypothesis about matrices. Note: This is NOT a generic |row|x|col| matrix. A generic matrix is one with arbitrary elements (variables instead of random numbers).
Example: randmatrix(3,2);
- transpose(|m|)
Take the transpose of matrix |m|. The transpose is converting the columns of |m| to the rows and the rows to the columns.
Example: transpose(matrix(3,2,[1,2,3,4,5,6]));
- inverse(|m|)
Take the inverse of the matrix |m|. Inverses are only defined when det(|m|) <> 0. That is, |m| must be a square matrix.
Example: inverse(matrix(2,2,[a,b,c,d]));
- evalm(|m|)
Prints out the matrix |m| into pretty matrix format.
Example: evalm(matrix(3,3,a));
- det(|m|)
Finds the determinant of |m| if it exists. Determinants are only defined for square matrices.
Example: det(matrix(2,2,[a,b,c,d]));
- linsolve(|m1|,|m2|)
Solves the system of equations with |m1| as the coefficient matrix and |m2| as the value matrix. That is, solves |m1|*|u| =|m2| where |u| is the nx1 matrix of unknowns.
Example: linsolve(randmatrix(3,3),randmatrix(3,1));
- charmat(|m|,lambda)
Finds the characteristic matrix (|m|-lambda*I).
Example: charmat(matrix(2,2,[a,b,c,d]),lambda);
- charpoly(|m|,lambda)
Returns the characteristic polynomial (det(|m|)-lambda*I).
Example: charpoly(matrix(2,2,[a,b,c,d,]),lambda);
- norm(|m|,|pow|)
Returns the normal of a matrix |m| with respect to |pow| power. For this class, |pow| is always two.
Example: norm(matrix(2,1,[a,b]),2);
Differential Equations
- lhs(|express|)
Returns the left hand side of |express|.
Example: lhs(2*x^2-4*x=14+x^3);
- rhs(|express|)
Returns the right hand side of |express|.
Example: rhs(2*x^2-4*x=14+x^3);
- dsolve(|eqn|,|var|)
Solves the differential equation given by |eqn| for |var|. Both |eqn| and |var| are defined differently than a normal equation (see example). {} can be used to enclose an initial condition.
Example1: dsolve(diff(y(x),x)=2*y(x),y(x));
Example2: dsolve({diff(y(x),x)=2*y(x),y(0)=1},y(x));
- implicitplot(|eqn|,|vars|=|range|)
Plots an implicit function, (one that is not in the form y=|eqn|, such as x^2+y^2=1). |vars| and |range| are of the same form as in plot().
Example: implicitplot({y=exp(x),x^2+y^2=1},x=1..2,y=1..2);
Last Updated April 19, 1996 by
Megak@Andrew.Cmu.Edu