Easy1.mws
This document contains information along the following lines
text and input lines (can switch from one to the other)
executing an input line (click anywhere in the line)
creating an extra input line
a few finicky features of Maple
What Went Wrong - some suggestions when maple gets huffy.
Problems between release 3 and release 4.
xxx.ms is a Maple V Release 3 file. It can
be read by Maple V Release 4
xxx.mws is a Maple V Release 4 file. It
can't be read by Maple V Release 3.
A summary of some points which come up in Easy 1.
the restart command resets all previous values
with(plots): brings up the plot package
: at the end of a line suppresses output from that line
; is used to complete the line when output is required
# is used to put comments on a line. Maple ignores characters after the #
:= is used for assignment to the left-hand side of what's on the left-hand side (as in x := 3 + 4*y )
= is used to express equality between expressions
inside an equation as in eqn1 := 3*x^2 = t ;
(here
eqn1 is assigned the equation 3*x^2 = t)
plotting a 'function' (plot command)
cursor moved around on graph will give coordinates in lower left (version
3)
cursor moved around on graph will give coordinates in upper right(version
4)
two or more functions may be plotted when grouped as a set, e. g. {x,y}
solving an equation (solve command)
solution via solve is 'exact' (rational fractions)
solution often has parts, which can be identified and used later on
floating point evaluation (evalf) is available
substituting a value in an expression (subs command; very handy later on)
Start of Easy1 ( for Maple V release 4. Things are slightly different in Release 3.)
The restart command resets all previous assignments and starts over.
A # on a line of Maple code lets you put comments on that line. The danger is that text from the comment may 'wrap around' and wind up on a separate line if the program is re-opened. The line coming up has a comment on it.
restart; with(plots): # begin and bring up plot package. Try changing to a semicolon at the end to see all the plot types.
Assignment statements use ' := ' like in pascal . We will assign 3 t + 4 t^2 to x. This is not a 'formal' definition of a function, but the informal definition works well in almost every situation.
x:=3*t+4*t^2; # define y as a 'function' of t; semicolon at end lets you see ouput
Plotting a function. Execute the command plot(x,t=0..4); . (click anywhere on the line). After a moment, a plot should appear.
plot (x,t=0..4);
Move the cursor around over the plot to a spot where you want the coordinates, then click the mouse. This gives the coordinates at the lower left (release 3) or upper left (release 4). It is very handy for identifying specific features of graphs. For practice, locate the value of t when x=5.0. (It's a little tricky, since X,Y are generic on the graph and in this case Y is playing the role of x, and X is playing the role of t. It should come out near t=0.8)
To ask for help on a topic or function just type '?' and the item. The
next command asks for help on the plot command. Most help screens
have examples at the bottom. You can cut and paste right into your program
from help if you wish.
?plot
y:=16-2*t^3;
plot({x,y},t=0..3); # note use of curly braces to collect things : plot both x and y as functions of t;
When we click in the plot, we find the x,y values (upper left corner in release 4, lower left corner in release 3) where xand y are equal (around x=1.33, y=11)
In the statement coming up, the equality statement is just a plain ' = ' ; there is no semicolon with it. This represents equality and not assignment.
Find the t value where x and y arequal; notice use of '=' without the semicolon in the solve command
sol:=solve(x=y , t);
This is not so helpful, so we get a floating point evaluation.
numsol:=evalf(sol);
Substitute t back into y to get the y value using the 'subs' command (2 ways)
yval:=subs(t=1.34,y);
xval:=subs(t=numsol[1],x);
xval and yval should be nearly the same.
Exercises for the user
1) Find the intersection(s) of y=1-3x and y=0.5+x^2; [ answer: around (0.16,0.53) and around (-3.16,10.5) ] ;
2) policeman and speeder
speeder travels at 60 m/s, constant speed.
cop starts from rest 1 sec after speeder goes by, constant acceleration
of 1.5 m/s^2
let s = speeder's position as a function of time
let p = policeman's position as a function of time
plot both and visually find where cop overtakes speeder solve for time when cop overtakes speeder, using 'solve' command, and evalf.
End of easy1.mws