The following are questions that have been submitted to the ITC Research Computing Support Group email address res-consult@virginia.edu concerning the technical computing software Maple.
How you can get maple to identify critical points
and inflection points on a graph?
How can I get a postscript printout of a Maple plot?
How do I use the Maple I/O commands 'read' and 'save'?
Once I have obtained a solution using the 'solve'
command, how do I access the solution variables for further manipulation?
How can I use nested do loops to generate a data set and then
plot it?
Is it possible to use a Taylor's expansion in
calculations like a polynomial?
I defined a function "a" in Maple:
a:=x^3-3*x^2+4.
I took the 1st and 2nd derivative of a, calling them "b" and "c".
b:=diff(a,x);
c:=diff(b,x);
Then b and c need to be set to 0 to get the critical values of x.
solve(b=0,x);
solve(c=0,x);
This yielded the 3 critical valuse for x=0,1,2.
Now to let Maple solve the function a at 0, 1, and 2:
x:=0;
a;
x:=1;
a;
x:=2;
a;
This yielded the 3 points (0,4), (1,2) and (2,0).
In order to do the plots, set x back to x with the command:
x:='x';
Bring in the "plots" package which lets you plot 2 functions on one
graph:
with(plots);
Define the 2 functions as "p" and "q":
p:=plot(a,x=-2..3);
q:=plot([0,4,1,2,2,0],style=POINT,symbol=BOX);
Graph them both:
display([p,q]);
DATE: 2-12-98
A way to get a printout of your plot from Maple is to issue the
command (in Maple):
plotsetup(postscript);
then issue your plot command.
The file "postscript.out" will be created in whatever directory you
issued the "xmaple" command. You can then view the postscript.out file
with ghostview or print it to a PostScript printer with the command lpr.
DATE: 6/5/96
The syntax of the save command is
save`somefile.m`;
and this will save the internal state of your current maple session
(including all variable definitions) in a binary (machine readable)
format. If you want to transfer this file by ftp to another machine,
you should do the transfer in binary (as opposed to ascii) mode. This
file can then be read into a new maple session with the command
read`somefile.m`;
and all the previous variable definitions will take effect. If the syntax
of the save is
save`somefile`;
then the state of the current seesion will be saved as ascii (human readable)
format, can be transferred by ftp in ascii mode and is read into a new
maple session with the command,
read`somefile`;
DATE: 6/5/96
You can use the 'assign' command to set the values of the
solution equal to the corresponding variables, e.g.
> sol:=solve({2*x-4*y+z=-1, 3*x+y-2*z=3, -5*x+y-2*z=4},{x,y,z});
51 15
sol := {z = - ----, x = -1/8, y = - ----}
28 56
> assign(sol);
> z;
51
- ----
28
> x;
-1/8
> y;
15
- ----
56
DATE: 10/28/96
The following example shows one way to do the above operations.
#Create X and Y arrays
> restart;
> Y:=array(0..100);
> Y_temp:=array(0..100);
#Initialize Y array
> for i from 0 to 20 do
> Y[i]:=0.9;
> od:
> for j from 21 to 100 do
> Y[j]:=0.2;
> od:
> x:=0.01;
> tau:=0.05*(x^2);
> R:=tau/(x^2);
#Generate values for Y array
> for k from 1 to 10 do
> Y_temp[0]:=Y[0]*(1-2*R) + 2*R*Y[1];
> for n from 1 to 99 do
> Y_temp[n]:=Y[n] + R*(Y[n+1] -2*Y[n] + Y[n-1]);
> od;
> Y_temp[100]:=Y[100]*(1-2*R) + 2*R*Y[100];
> for m from 0 to 100 do
> Y[m]:=Y_temp[m];
> od;
> od:
#Generate values for X array
> X:=array(0..100);
> for p from 0 to 100 do
> X[p]:=.01*p;
> od:
#Convert X and Y arrays to lists, merge and plot.
> Y1:=convert(Y,'list');
> X1:=convert(X,'list');
> pair:=(x,y)->[x,y];
> P:=zip(pair, X1, Y1);
> plot(P);
DATE: 2-12-98
Maple has trouble knowing what to do with the higher-order residual terms.
I think the way around this is to convert the series to polynomials and then
combine them, letting the higher-order terms be implicit. The following works.
> a1:=taylor(c(2*x),x=0,6);
> a2:=taylor(c(-x),x=0,6);
> b1:=convert(a1,polynom);
> b2:=convert(a2,polynom);
> a3:=b1+b2;
DATE: 12-17-97