Vector valued functions in Maple 7
This worksheet is called "vectorvalued7.mws".
Type in the commands below. You do not need to type in the comments.
Or, visit my web page http://www-math.bgsu.edu/~zirbel/calc3 and look for the worksheet called vectorvalued7.mws . You can download it following the directions on the web page.
If you have trouble printing: Make your worksheets shorter; split one assignment into several worksheets so none of them has very many graphs. If you still have trouble, at the bottom left of a Macintosh screen is a tab. Click and pull it out. Click on the colored bars and set the number of colors to 256 (rather than millions). This avoids the memory trouble that apparently causes Maple to mess up when printing graphics.
Vector-valued functions in two dimensions
The first step is to define a vector-valued function r (t).
> restart; This clears Maple's memory and previous definitions. It helps Maple avoid crashing.
> r:=t->2*cos(2*t)*[cos(t),sin(t)]; This says that r is defined to be (that's what := means) a function taking t to the expression 2cos(2t)[cos(t),sin(t)]. We all know that the vector [cos(t),sin(t)] gives you circular motion. Multiplying by the scalar 2cos(2t) changes the radius of the circle as a function of time, and even makes the "radius" negative. The resulting graph, as you will see below, is a cloverleaf.
> r(t); r(t)[1]; r(t)[2]; Display what r(t) is. If you want the first and second components of the vector, you say this with [1] and [2] after you type r(t).
> plot([evalm(r(t))[1],evalm(r(t))[2],t=0..2*Pi]); This is the best way to plot r(t), since the same command will work for more complicated vector valued functions, as you will see below. In this plot command, the two components of r(t) are listed separately. The command evalm does scalar multiplication and vector addition, if any needs to be done.
> v:=t->-4*sin(2*t)*[cos(t),sin(t)] + 2*cos(2*t)*[-sin(t),cos(t)]; I have tried and tried, but I have not found a satisfactory way to have Maple compute the derivative of r(t). (There are lots of ways of trying, but none of them makes v a function of the same sort that r is.) So I computed the derivative by hand and typed it in.
> l:=s->r(1) + s*v(1); This is the parametric form of the tangent line at time 1. Here l is a function of s . Please note how easy it is to make up the tangent line. It is a function taking s to r(1) + s v(1), just what we want.
> l(s); l(2); eval(l); This is how I check that the definition of l is doing what I want it to do. You don't need to type this in if you just want to see the tangent line.
> p1:=plot([evalm(r(t))[1],evalm(r(t))[2],t=0..2*Pi]): Store the graph of r as p1 . Note the colon at the end of the command!
> p2:=plot([evalm(l(s))[1],evalm(l(s))[2],s=-0.5..0.5],color=black): Store the graph of l as p2 .
> with(plots): Load some additional plotting features. This is necessary for the next line to work!
Warning, the name changecoords has been redefined
> display({p1,p2}); Display these two graphs together. This is the standard way to display two vector valued functions in the same graph.
> with(linalg): Load the package of functions which do linear algebra things, like computing the length of a vector.
Warning, the protected names norm and trace have been redefined and unprotected
> speed:=t->norm(v(t),2); The speed function, called v in class. The function norm(.,2) computes the length of v(t).
> plot(speed,0..2*Pi); Graph of speed over time.
> arclength:=evalf(Int(speed(t),t=0..2*Pi)); Evaluate arc length numerically by integrating the speed.
Building more interesting functions
Here is how to build up something more interesting based on what we did above.
> restart;
> r:=t->2*cos(2*t)*[cos(t),sin(t)]; The same cloverleaf as above.
> q:=t->[cos(t),sin(t)]; Circular motion.
> s:=t->r(t) + 0.1*q(80*t); Start with r(t), then add a scaled down and speeded up version of q.
> plot([evalm(s(t))[1],evalm(s(t))[2],t=0..2*Pi],numpoints=500);
Vector-valued functions in three dimensions
This example includes all the necessary commands, so it can be run separately from what is above.
> restart;
> with(plots): Load the package of functions that includes spacecurve.
Warning, the name changecoords has been redefined
> r:=t->[2*cos(t),t/4,2*sin(t)]; Define a helix that circles in the xz plane and moves linearly along the y axis.
> p1:=spacecurve(evalm(r(t)),t=0..12*Pi,axes=BOXED,thickness=2,numpoints=800,labels=["x axis","y axis","z axis"]):
> display(p1); Typing evalm here will be helpful in situations where r has a more complex definition.
> v:=t->[-2*sin(t),1/4,2*cos(t)]; I computed the derivative by hand and typed it in.
>
l:=s->r(Pi/3)+s*v(Pi/3);
The equation for the tangent line at time
/3. Hint: same formula as for two-dimensional tangent lines.
> p2:=spacecurve(evalm(l(s)),s=-1..1,color=black): Prepare and save a plot of the tangent line.
> display({p1,p2});
> q:=t->[0,cos(t),sin(t)]; Circular motion parallel to the yz plane.
> s:=t->r(t) + 0.2*q(40*t); Add small quick circles to r.
> spacecurve(s(t),t=0..4*Pi,axes=BOXED,thickness=2,numpoints=800,labels=["x axis","y axis","z axis"]);