Professional Documents
Culture Documents
S.Thota An Introduction To Maple AMS 2012, Allahabad 1 / 21
S.Thota An Introduction To Maple AMS 2012, Allahabad 1 / 21
Srinivasarao Thota
Department of Mathematics
Motilal Nehru National Institute of Technology
Allahabad, India
srinithota[at]ymail.com
National Conference on
Advances in Mathematical Sciences
Motilal Nehru National Institute of Technology
Allahabad, India
1 Introduction
2 Expressions
3 Functions
4 Solutions of Equations
5 Solving a System of Equations for Several Unknowns
6 Solving Differential Equations
7 Procedures, Variables, and Extending Maple
8 Implementing Packages using Modules
9 Three-dimensional plotting
10 Create a 2-D or 3-D animation on one parameter
11 Maple Help
12 References
> restart;
To plot an expression
say f = x2 + xy
> f:=x2 +x*y; defines f as an expression
> r:=subs(x=1,y=3,f); substitutes x = 1 and y = 3 into f.
S.Thota () An Introduction to Maple AMS 2012, Allahabad 4 / 21
Functions
Order
(range 1, function 1, range 2, function 2, range 3, function 3, ...)
For example
Solve the system numerically, but may give only one solution since no
range is specified.
help
> ?implicitplot for more help with the implicitplot command
> ?fsolve for more help with the fsolve command
Derivatives of functions
> diff(f,x); gives f’(x),
> diff(f,x,x); gives f”(x) or > diff(f,x$2); gives f”(x),
> diff(f,x,x,x); gives f(3) (x), or > diff(f,x$3); gives f(3) (x),
etc.
Defining an ordinary differential equation.
Nested Procedures
We can define a Maple procedure within another Maple procedure.
Local Variables
Local variables can exist after the procedure which created them has
exited. This feature allows a procedure to return a procedure. The new
procedure requires a unique place to store information.
Interactive Input
We can write interactive procedures, querying the user for missing
information or creating an interactive tutorial or a test.
Extending Maple
The Maple software includes useful mechanisms for extending Maple
functionality, which reduce the need to write special purpose procedures.
Several Maple commands can be extended.
hello:=proc()
print(‘hello world‘);
end;
Wishing:=proc()
local name;
print(‘What is your name? ‘);
name := readline(terminal);
print(‘Hello‘||name);
end;
double:=proc(n)
n*2;
end;
S.Thota () An Introduction to Maple AMS 2012, Allahabad 14 / 21
Here is a variant of the procedure that responds in words.
printdouble:=proc(n::numeric)
printf("Double of %a is %.1f.", n, n*2);
end;
Calling proc
callingfun:=proc(n::posint)
print(n);
halfdouble(n);
hello();
end;
S.Thota () An Introduction to Maple AMS 2012, Allahabad 15 / 21
Implementing Packages using Modules
Example:
MyPackage := module()
export f1, f2;
local loc1;
option package;
f1 := proc() loc1 end proc;
f2 := proc(v) loc1 := v end proc;
loc1 := 2; end module:
savelib(’MyPackage’);
restart;
with(MyPackage);
Calling Sequence
plot3d(expr, x=a..b, y=c..d, opts)
plot3d(f, a..b, c..d, opts)
plot3d([exprf, exprg, exprh], s=a..b, t=c..d, opts)
plot3d([f, g, h], a..b, c..d, opts)
For example:
plot3d(sin(x+y),x=-1..1,y=-1..1)
plot3d(binomial, 0..5,0..5,grid=[20,20])
plot3d([1,x,y],x=0..2π,y=0..2π,coords=toroidal(10), scaling =
constrained)
plot3d([1,x,y],x=0..2π,y=0..2π,coords=toroidal(10),scaling=contour)
plot3d([1,x,y],x=0..2π,y=0..2π,coords=toroidal(10),colour=x)
Calling Sequence
animate(plotcommand, plotargs, t=a..b, options)
animate(plotcommand, plotargs, t=L, options)
For example:
with(plots):
animate(plot,[Ax2 ,x=-4..4],A=-3..3)
animate(plot,[Ax2 ,x=-4..4],A=-3..3,trace=5,frames=50)
sinewave:=plot(sin(x),x=0..4π):
animate(spacecurve,[[cos(t),sin(t),(2+sin(A))t], t=0..20 opts],
A=0..2π)
or enter
1 > ?index
2 > ?command