Maple/Lesson 1: Getting Started
Chapter 1: Getting Started with Maple
Before You Begin
All the orders given to Maple are in the areas marked with >.
These are the input areas.
Press enter to give the software the order.
>sample code;
The lines of code must end with either a semicolon or a colon. Note the difference between them:
>p - ln( p );
>p - ln (p ):
If the line of code ends with a semicolon, the order is validated and the software displays the answer in the output area. If the line of code ends with a colon, the order is validated, but the answer is not displayed.
Simple computations with Maple
>(1-1/7)*(1+2/3)^2;
> (25)^(1/2);
>factorial(15);
>15!;
>sqrt(81);
>sqrt(56.81);
>%^2;
Using variables with Maple
You can affect a value to a variable. Here, 2.14 is affected to the p variable. We can then compute .
>p:=2.14;
>p - ln(p);
You can also use more than one variable in a single equation:
>x := 2*a-p;
>x-sqrt(a*p);
>expr := a*x^2 + b*x + c = 0;
Using functions with Maple
Maple has a wide range of functions to help you manipulate mathematical expressions:
>f := (a+b)^6;
>expand(f);
>factor(%);
>%%;
>sin(x)^2+cos(x)^2;
>simplify(%);
Here, the % symbol recalls the last computation made by Maple. %% means you recalls the computation made two steps back. To obtain the the computation made n steps back, repeat the % symbol n times.
You can also substitute variables in an expression with the subs() function:
>subs(a=c, f);
>subs(a=2, b=4/5, f);
The evalf() function evaluates the numeric value of an expression. You may also specify the desired precision.
>evalf(sqrt(3));
>evalf(sqrt(3), 50);
>evalf[50](sqrt(3));
print(), lprint() and printf() are functions used to display a mathematical expression. print() displays the expression normally, lprint() displays the function in Courier font and to the left of the screen and printf() is the same function used in C or C++ language, where you can display variables using formats: %d represents an integer variable, %f a floating number and \n breaks a line of text:
>f:=a-3/a+1/(a*a+1);
>print(f);
>lprint(f);
a-3/a+1/(a^2+1)
>printf("%d %f \n",123,1234/567);
123 2.176367
Defining a function with Maple
>f := t -> sin(t) - t;
>f(3*x + 2);
>g:=(u,v,w)->1/u+exp(u+v)+(u-v+w)^2;
>g(2*a,b,3*c);
Calculus with Maple
Maple can be used to find the integral of a given function. For example, to get the integral of the f(t) function according to t and the g(u,v,w) function according to v, the following commands can be entered:
>Int(f(t), t) = int(f(t), t);
>Int(g(u,v,w), v) = int(g(u,v,w), v);
>Int(f(t),t=0..Pi)=int(f(t),t=0..Pi);
Note the difference between Int() and int(). The first one displays the integral while the latter computes it.
Limits, sums and products with Maple
You can also find numeric and symbolic values of sums, limits and products using respectively the functions sum(), limit() and product():
>limit((2*t-3)/(3*t+4),t=infinity);
>limit((2*t-3)/(3*t+4),t=-4/3,right); #right-bound of the limit
Sum(i^2,i=1..10)=sum(i^2,i=1..10);
Product(1/i,i=1..10)=product(1/i,i=1..10);
The functions Sum() and Product() only display a Sigma and a Pi symbol; they do not actually compute the sum or the product.
Solving equations with Maple
The solve(eqn,x) function tries to find the value of x in eqn. You can also use more variables or more equations using solve({eqn1,eqn2,...},{x,y,...}):
solve(2*t+3=-t+6*sqrt(2));
solve(t-15/4*u=5/2*(u-t)+3,u);
solve({a-b=2,a+3*b=7},{a,b});
Sometimes, the exact solution of an equation might not be found. You can then use the fsolve() to get a numerical approximation:
fsolve(cos(t)=t);
fsolve({t^3+u=1,u-(t-1)^3=t},{t,u});
Plotting functions with Maple
To plot a f(x) function, use plot(f(x),x) function:
plot(sin(t)/t,t=-20..20,title="function t ---> sin t / t");

plot3d(x*exp(-x^2-y^2),x=-2..2,y=-2..2,color=x,orientation=[120,75]);
