This worksheet is called "vectorvalued.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 vectorvalued.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). Based on the way Maple does real-valued functions of one variable, one might think you would type r := proc (t) options operator, arrow; vector([x(t)... , but you don't. Instead, you put a function in each component of a vector as follows:

> r:=vector([t->2*cos(2*t)*cos(t),t->2*cos(2*t)*sin(t)]);

r := vector([proc (t) options operator, arrow; 2*co...

> r(t); r[1](t); r[2](t); This is how you get at r and the two components of r .

vector([2*cos(2*t)*cos(t), 2*cos(2*t)*sin(t)])

2*cos(2*t)*cos(t)

2*cos(2*t)*sin(t)

> plot(r(t),t=0..20); This is what we might expect to do to plot r, but it is not.

[Maple Plot]

> plot([r[1](t),r[2](t),t=0..2*Pi]); One needs to specify the two components here. You can't just use r(t). See p. 151 of Gresser's book.

[Maple Plot]

> v:=map(D,r); This is how you differentiate. The map command applies the differentiation operator D to each component of r separately. It means "multiple application".

v := vector([proc (t) options operator, arrow; -4*s...

> r(1); v(1); Compute the position and derivative vectors at time 1.

vector([2*cos(2)*cos(1), 2*cos(2)*sin(1)])

vector([-4*sin(2)*cos(1)-2*cos(2)*sin(1), -4*sin(2)...

> evalf(r(1)); evalf(v(1)); Evaluate (approximate) these numerically.

vector([-.4496901908, -.7003509766])

vector([-1.264831009, -3.510279796])

> with(linalg): This is really important! This loads functions that do things like adding vectors.

Warning, the protected names norm and trace have been redefined and unprotected

> l:=map(unapply,matadd(r(1), scalarmul(v(1),s)),s); This is the parametric form of the tangent line at time 1. Here l is a function of s . The command unapply turns an expression into a function.

l := vector([proc (s) options operator, arrow; 2*co...
l := vector([proc (s) options operator, arrow; 2*co...

> p1:=plot([r[1](t),r[2](t),t=0..2*Pi]): Store the graph of r as p1 . Note the colon!

> p2:=plot([l[1](s),l[2](s),s=-0.75..0.75]): 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.

[Maple Plot]

> speed:=t->norm(v(t),2); The speed function, called v in class.

speed := proc (t) options operator, arrow; norm(v(t...

> plot(speed,0..2*Pi); Graph of speed over time.

[Maple Plot]

> arclength:=evalf(Int(speed(t),t=0..2*Pi)); Evaluate arc length numerically. Slow.

arclength := 19.37689644

> a:=map(D,v); The acceleration vector.

a := vector([proc (t) options operator, arrow; -10*...

> curvature:=t->abs(v[1](t)*a[2](t)-v[2](t)*a[1](t))/speed(t)^3; Curvature as a function of time. Since these are two-dimensional vectors, imagine adding a third component that is zero before taking the cross product of v and a . The cross product is then in the k direction, and its length is the absolute value in the definition of curvature.

curvature := proc (t) options operator, arrow; abs(...

> plot(curvature,0..2*Pi); The curvature is largest at the far right, left, top, bottom of the graph of r .

[Maple Plot]

Building more interesting functions

Here is how to build up something more interesting based on what we did above. Enter the lines above first.

> q:=vector([t->cos(40*t),t->sin(40*t)]); A new vector-valued function doing quick circular motion.

q := vector([proc (t) options operator, arrow; cos(...

> p:=scalarmul(q,0.2); Make the circle have radius 0.2. p:=0.2*q; doesn't work.

p := vector([.2*q[1], .2*q[2]])

> s:=matadd(p,r); Add this motion on top of the cloverleaf above. This is how to add vector-valued functions in Maple.

s := vector([.2*q[1]+r[1], .2*q[2]+r[2]])

> plot([s[1](t),s[2](t),t=0..20]); Plot the new vector-valued function.

[Maple Plot]

Vector-valued functions in three dimensions

This example includes all the necessary commands, so it can be run separately from what is above.

> with(plots): with(linalg):

> r:=vector([t->2*cos(t), t->t/4, t->2*sin(t)]);

r := vector([proc (t) options operator, arrow; 2*co...

> p1:=spacecurve(r(t),t=0..12*Pi,axes=BOXED,thickness=2,numpoints=800,labels=["x axis","y axis","z axis"]):

> display(p1);

[Maple Plot]

> v:=map(D,r);

v := vector([proc (t) options operator, arrow; -2*s...

> l:=map(unapply,matadd(r(Pi/3), scalarmul(v(Pi/3),s)),s); The equation for the tangent line at time pi /3. Hint: same formula as for two-dimensional tangent lines.

l := vector([proc (s) options operator, arrow; 1-s*...

> p2:=spacecurve(l(s),s=-1..1):

> display({p1,p2});

[Maple Plot]