MAPLE TEXT COMMANDS FOR CHAPTER 0
TUTORIAL 0.3: SIMPLE MAPLE PROGRAMS
Procedures: The norm of a vector in three-dimensional space.
|
> |
norm3d:=proc(a,b,c) sqrt(a^2+b^2+c^2) end; |
|
5 |
(1) |
For..do..end do loop: Sum the natural numbers from 1 to 100.
|
> |
i:=`i`:total:=0: |
|
|
(2) |
If..then..elif..else: Determine whether p is less than or not less than 2.
|
> |
p:=4: |
|
p is not less than 2 |
Arrays and sequences: Evaluate the first 25 terms of the Fibonacci sequence.
|
> |
F:=array(1..10000): |
|
|
(3) |
Iteration: List the final 10 iterates for the logistic map.
|
> |
mu:=3.2:x[0]:=0.2: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(4) |
Multiple plots: Using the display command.
|
> |
with(plots): |
|
|
Multiple plot with text: Solution curves to two initial value problems.
|
> |
restart:with(DEtools):with(plots): |
|
|
Interactive Exploration: An interactive parameter Maplet pops up with a parameter slider.
|
> |
restart:with(DEtools):with(plots): |
|
|
Interactive Exploration: Consider the system of differential equations
used to model the chemical system
X→Y→Z. Show how the solution curves
vary as the rate constants,
and
, vary.
|
> |
sys1:=diff(x(t),t)=-a*x(t),diff(y(t),t)=a*x(t)-b*y(t),diff(z(t),t)=b*y(t); |
|
|
(5) |
|
> |
dsolve([sys1,x(0)=10,y(0)=0,z(0)=0]); |
|
|
(6) |
|
> |
interactiveparams(plot,[{10*exp(-a*t),10*a*exp(-b*t)/(a-b)-10*a*exp(-a*t)/(a-b),(10*exp(-a*t)*b-10*exp(-b*t)*a^2/(a-b)+10*exp(-b*t)*a*b/(a-b)+10*a-10*b)/(a-b)},t=0..30],a=0.1..0.9,b=0.1..0.8); |
|
|
Figure: A plot when
and
.
End of Tutorial 0.3