Welcome to the Rutgers Maple Help Pages!


 

Why learn Maple? Beginning Maple Common
Maple errors
More about
Maple
Using
Maple files
Other links
about Maple


In this Section: arithmetic | algebra | calculus | graphing


Beginning Maple


Arithmetic

Addition

> 3+2;
5

Subtraction

> 3-2;
1

Multiplication

> 3*2;
6

Division

> 4/2;
2
Note: When you type the division sign in Maple 10, it will move your cursor to the bottom half of a fraction. Make sure to use the arrow keys or your mouse to put your cursor where you want it before continuing your input!

Power

> 3^2;
9
Note: When you type the power sign in Maple 10, it will move your cursor to the exponent. Make sure to use the arrow keys or your mouse to put the cursor where you want it before continuing your input.

Ditto Marker

> 3^2;
9
> %+7;
16
The percent sign (%) tells maple to use the previous answer in the current computation.

Combinations of operations & parentheses

> 2*3+7;
13
> 2*(3+7);
20
You can combine many operations at once, using parentheses as necessary.

Square Root

> sqrt(16);
4

Other manipulations

> (sqrt(2)-1)^5;

> expand(%);

> evalf(sqrt(2));
1.414213562
Maple prefers to leave answer in "exact" form unless you tell it to do something different. expand(); is one way of telling Maple to change its output. evalf(); tells maple to give a decimal answer instead of an "exact" one.

[back to the top | arithmetic | algebra | calculus | graphing]




Algebra

Expanding Expressions

> (x+2*y)^5;

> expand(%);


Assigning Values to Variables

> x=2;
x=2
> x
x
> x:=2;
x:=2
> x;
2
> x^3;
8
To assign a value to a variable, make sure to use colon-equals instead of just an equals sign. To Maple, "x=2" is an equation, while "x:=2" actually assigns the value 2 to the variable x.

Unassigning Values

> unassign('x');
The unassign command unassigns just one variable at a time. Make sure to use the single quotation mark that's on the same key as the double quotation mark.
> restart;
The restart; command unassigns all variables at once. It makes Maple behave as if you have just opened a new Maple session.

Expressions

> sumsqrts:=sqrt(x)+sqrt(y);

> expand(sumsqrts^3);

Maple can do symbolic manipulation quite well. You can give names to expressions (like sumsqrts above) using colon-equals.

Factoring

> factor(y^4-16);

Maple can factor algebraic expressions with the factor command. If you want to factor an integer, use ifactor(); instead.
> factor(y^4-16,I);

> factor(x^7-42*x+19,complex);

If you want to factor an expression that has imaginary or complex roots, use factor(expression, I); or factor(expression, complex); respectively.

Constants

Maple knows several important constants. You can use I for sqrt(-1); and Pi for 3.14159..... To use E, you should say exp(1);

Substitution

Maple can substitute values into algebraic expressions.
> subs(a=t, 5*a^3+3*t+a+2*sqrt(a));

substitutes t for a in the above expression.
> subs({a=t,b=t^2,c=t^3}, a*b^2*c^3);

substitutes t for a, t^2 for b, and t^3 for c in the above expression.

Solving equations

Maple can solve single equations or systems of equations.
> solve(x^3=7*x+1,x);

solves x^3=7*x+1 for x.
> solve({a*b+3=2,a+b=0});

solves the two equation system given above.
> solve({a*b+3=2, a+b=1});

solves the two equation system above. What's different this time?
> solve(x^7-x^2+1);

since the input was an expression instead of an equation, this command solves x^7-x^2+1=0.
> fsolve(x^7-x^2+1);
-0.8398331470
when you want a decimal answer, use fsolve.

[back to the top | arithmetic | algebra | calculus | graphing]




Calculus

Limits

Maple can compute limits!
> limit(x^2,x=2);
4
computes the limit of x^2 as x goes to 2.
Maple even knows when limits are undefined.
> limit(abs(x)/x,x=0);
undefined
Maple can compute limits from the left and from the right as follows:
> limit(abs(x)/x,x=0,left);
-1
> limit(abs(x)/x,x=0,right);
1

Derivatives

Maple computes derivatives using diff(f,x); where f is the function whose derivative you want, and x is the variable.
> diff(3*x^7-22.1*x^2,x);

Sometimes it is useful to save the function to a variable, and then work from there:
> Q:=sin(x^2*sqrt(x+1));

> diff(Q,x);

Taking multiple derivatives is similar. To compute the 2nd derivative of Q try:
> diff(Q,x,x);

To save space, you can also compute higher derivatives by using the $ operator. For example,
> diff(Q,x$10);
computes the 10th derivative of Q.

Integrals

Maple computes integrals using the int(f,x); command where f is the function to be integrated and x is the variable of integration.
> int(x*sqrt(x+2),x);

Again, it may be useful to give your function a name, and work with it from there:
> V:=exp(sin(x));

> int(V,w);

> int(V,x);

Do you understand why we got two different answers here? What's going on in each of these two commands?
> int(x^3,x=1/7..b);

You can evaluate definite integrals by including bounds as above. Make sure there are exactly 2 periods between the bounds.

Defining Functions

We have already seen how to give names to expressions using colon-equals. You may also find it useful to define a function.
To define a function, use colon-equals, followed by x->function as below.
> N:=x->arctan(x^3);

Now, N is a function that can take input and give output. Try the following:
> N(2);

> N(5*z);

You can also manipulate this function.
> diff(N(x),x);

> M:=D(N);

> int(N(x),x);

> int(N,x);

What is the difference between the previous two lines? When N is a function, note the difference between using N and N(x).
When you have a function, an alternate way of computing derivatives is:
> D(N);



[back to the top | arithmetic | algebra | calculus | graphing]




2D-Graphing

To plot a simple graph of the form y=f(x), use the plot command:
> plot(x^3-6*x+1,x);

plots a graph of y=x^3-6*x+1.
You can choose the domain of your graph in the following way:
> plot(sin(100/x),x=.1..1);

You can also plot more than one graph at a time:
> plot({x^2,x^3}, x=4..5);

As before, it could be useful to give your function a name, and work with it from there:
> P:=w->exp(w)/(1+w^2);

> plot({P(t),D(P)(t)},t=-2..5);

The plots package contains many other useful graphing tools. For example, implicitplot will graph an equation that is not solved for y:
> with(plots):
> implicitplot(x^3-5*x*y^2=7,x=-5..5,y=-5..5);



[back to the top | arithmetic | algebra | calculus | graphing]


Maintained by Last modified 9/5/2006. Address questions to the Undergraduate Office of the Department of Mathematics.