Maple Lab 4 (Spring 2007 Math 251 Sections 05-07) 

Background Worksheet. 

 

It's a good idea to start every sheet with the restart command. Maple remembers everything that 

you do, so the restart command gives you a fresh start without having to shutdown and restart  

the program itself! 

 

> restart; 1
 

 

A Quick Note for Typing in Maple: 

To create new text groups such as this use the button labeled "T" above. To create a new execution group  

(the lines with maple commands which start with ">") you can use the button labeled "[>" or the keyboard  

shortcut "Ctrl+J". To insert a group before the cursor use "Ctrl+K".  

 

To delete a line of input or Maple output you can use the keyboard shortcut "Ctrl+Delete". To begin 

another line in an execution group use "Shift+Enter". Remember that "Enter" alone will just execute 

the command you've typed. 

 

For this lab we will need the "plots" package along with the "VectorCalculus" package. 

 

> with(plots); 1; with(VectorCalculus); 1
 

Warning, the name changecoords has been redefined 

[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
[Interactive, animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, cylinderplot, densityplot, ...
 

Warning, the assigned names `<,>` and `<|>` now have a global binding 

Warning, these protected names have been redefined and unprotected: `*`, `+`, `-`, `.`, D, Vector, diff, int, limit, series 

[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
[`&x`, `*`, `+`, `-`, `.`, `<,>`, `<|>`, AddCoordinates, ArcLength, BasisFormat, Binormal, CrossProd, CrossProduct, Curl, Curvature, D, Del, DirectionalDiff, Divergence, DotProd, DotProduct, Flux, Get...
 

 

We will be exploring Chapter 16 material using Maple. Specifically, we will be looking at: 

computing "div" and "curl", finding potential functions, computing line integrals, and graphing orientations. 

 

First we define the vector field F(x, y, z) = `<,>`(x^2+y^2, x*y*z, x^2+z^2)and test to see if it's conservative 

by computing Curl(F). The curl of F will be the zero vector field if it's conservative. 

[Notice that we set the coordinates to be "cartesian" coordinates. These are our standard rectangular coordinates. 

Maple can also handle other coordinate systems. But we will stick to cartesian coordinates in this lab.] 

 

> F := VectorField(`<,>`(x^2+y^2, 2*x*y, y^2-4*x*z), 'cartesian'[x, y, z]); 1
 

(Typesetting:-mprintslash)([F := Vector[column]([[x^2+y^2], [2*x*y], [y^2-4*x*z]], [ 

> Curl(F); 1
 

(Typesetting:-mprintslash)([Vector[column]([[2*y], [4*z], [0]], [ 

 

Since Curl(F) is not zero, we conclude that F is not conservative. However, the divergence 

of F is zero. 

 

> Divergence(F); 1
 

0 

 

Let's try another vector field. Let F(x, y, z) = `<,>`(y*z+3*x^2*y^2+2*x, x*z+2*x^3*y+z*cos(y), x*y+sin(y)) 

 

> F := VectorField(`<,>`(y*z+3*x^2*y^2+2*x, x*z+2*x^3*y+z*cos(y), x*y+sin(y)), 'cartesian'[x, y, z]); 1
F := VectorField(`<,>`(y*z+3*x^2*y^2+2*x, x*z+2*x^3*y+z*cos(y), x*y+sin(y)), 'cartesian'[x, y, z]); 1
 

(Typesetting:-mprintslash)([F := Vector[column]([[y*z+3*x^2*y^2+2*x], [x*z+2*x^3*y+z*cos(y)], [x*y+sin(y)]], [ 

> Curl(F); 1
 

(Typesetting:-mprintslash)([Vector[column]([[0], [0], [0]], [ 

 

This time Curl(F) = 0. Let's find a potential function for F. 

 

> f := ScalarPotential(F); 1
 

(Typesetting:-mprintslash)([f := y*z*x+x^3*y^2+x^2+z*sin(y)], [y*z*x+x^3*y^2+x^2+z*sin(y)]) 

> Gradient(f, 'cartesian'[x, y, z]); 1
 

(Typesetting:-mprintslash)([Vector[column]([[y*z+3*x^2*y^2+2*x], [x*z+2*x^3*y+z*cos(y)], [x*y+sin(y)]], [ 

 

Consider the line integral  where C is the upper-half of the circle lying in the xy-plane  

centered at (2,0,0) with radius 2 oriented counter-clockwise. Let's compute this integral three  

different ways.  

 

First, we compute it directly after parametrizing C as follows: 

  x(t) = 2*cos(t)+2,   y(t) = 2*sin(t),  and  z(t) = 0 

where 0 <= t and t <= Pi. 

 

> r := `<,>`(2*cos(t)+2, 2*sin(t), 0); 1
 

(Typesetting:-mprintslash)([r := Vector[column]([[2*cos(t)+2], [2*sin(t)], [0]], [ 

> rPrime := diff(r, t); 1
 

(Typesetting:-mprintslash)([rPrime := Vector[column]([[-2*sin(t)], [2*cos(t)], [0]], [ 

 

We plug our parametrization r into our vector fieldF using the evalVF (evaluate vector field 

command) and dot the result with the derivative of our parametrization r. Then we must integrate 

from 0 to Pi (half way around the circle). 

 

> int(Typesetting:-delayDotProduct(evalVF(F, r), rPrime), t = 0 .. Pi); 1
 

-16 

 

Remember that our vector field is conservative. Let's use the fundamental theorem of line 

integrals to find the answer.  

 

We all ready have a potential function. We also need to find the start and end points of 

our curve C.  

 

> subs(t = 0, r); 1
 

(Typesetting:-mprintslash)([Vector[column]([[4], [0], [0]], [ 

> subs(t = Pi, r); 1
 

(Typesetting:-mprintslash)([Vector[column]([[0], [0], [0]], [ 

 

The start is (4,0,0) and the end is (0,0,0). 

 

> subs({x = 0, y = 0, z = 0}, f)-subs({y = 0, z = 0, x = 4}, f); 1
 

-16 

 

Now let's use compute the integral using the relation: 

   

 

We need to compute both T (the unit tangent for C) and ds. Recall that  

 

> rPrimeLength := `assuming`([simplify(sqrt(Typesetting:-delayDotProduct(rPrime, rPrime)))], [t::real]); 1
 

(Typesetting:-mprintslash)([rPrimeLength := 2], [2]) 

> rTangent := rPrime/rPrimeLength; 1
 

(Typesetting:-mprintslash)([rTangent := Vector[column]([[-sin(t)], [cos(t)], [0]], [ 

> int(Typesetting:-delayDotProduct(evalVF(F, r), rTangent)*rPrimeLength, t = 0 .. Pi); 1
 

-16 

 

We deal with two different types of surfaces in this class.  

1) Level surfaces defined by F(x, y, z) = K where Kis some fixed constant. 

2) Parametrized surfaces defined by r(u, v) = `<,>`(x(u, v), y(u, v), z(u, v)) where `in`(u, v, R). 

 

An orientation for a surface is a smooth choice of unit normal vectors -- that is an orientation 

is a vector field on a surface such that at each point the vector field describes a (unit length) normal  

vector for the tangent plane of the surface. 

 

We know that Typesetting:-delayGradient(F) gives us normal vectors for the tangent planes of a level surface F(x, y, z) = K. 

So (as long as  Typesetting:-delayGradient(F)0 ) we get the orientations: n = Typesetting:-delayGradient(F)/abs(`∇F`) and n = -Typesetting:-delayGradient(F)/abs(`∇F`) for our surface F(x, y, z) = K. 

 

If our surface is parametrized by we can find tangent 

vectors for our surface by computing r[u](u, v) = `∂`*r/`∂u` and `∂`*r/`∂u` = `<,>`(`∂x`/`∂u`, `∂`*y/`∂u`, `∂z`/`∂u`)and r[v](u, v) = `∂`*r/`∂v` and `∂`*r/`∂v` = `<,>`(`∂x`/`∂v`, `∂`*y/`∂v`, `∂z`/`∂v`). 

Thus we must have that Typesetting:-delayCrossProduct(r[u], r[v]) gives normal vectors for the tangent planes of our surface. 

So (as long as Typesetting:-delayCrossProduct(r[u], r[v]) <> 0 ) we get the orientations: n = Typesetting:-delayCrossProduct(r[u], r[v])/abs(Typesetting:-delayCrossProduct(r[u], r[v])) and n = -Typesetting:-delayCrossProduct(r[u], r[v])/abs(Typesetting:-delayCrossProduct(r[u], r[v])) 

 

Consider the surface S defined by z = x^2+y^2 where x^2+y^2 <= 4.  

 

We can view S as the level surface 0 where x^2+y^2 <= 4. Thus we 

get the orientations: 

 

> F := x^2+y^2-z; 1
 

(Typesetting:-mprintslash)([F := x^2+y^2-z], [x^2+y^2-z]) 

> gradF := Gradient(F, 'cartesian'[x, y, z]); 1
 

(Typesetting:-mprintslash)([gradF := Vector[column]([[2*x], [2*y], [-1]], [ 

> gradFLength := sqrt(Typesetting:-delayDotProduct(gradF, gradF)); 1
 

(Typesetting:-mprintslash)([gradFLength := (1+4*x^2+4*y^2)^(1/2)], [(1+4*x^2+4*y^2)^(1/2)]) 

 

"Downward" orientation: 

 

> n := gradF/gradFLength; 1
 

(Typesetting:-mprintslash)([n := Vector[column]([[2*x/(1+4*x^2+4*y^2)^(1/2)], [2*y/(1+4*x^2+4*y^2)^(1/2)], [-1/(1+4*x^2+4*y^2)^(1/2)]], [ 

 

"Upward" orientation: 

 

> -n; 1
 

(Typesetting:-mprintslash)([Vector[column]([[-2*x/(1+4*x^2+4*y^2)^(1/2)], [-2*y/(1+4*x^2+4*y^2)^(1/2)], [1/(1+4*x^2+4*y^2)^(1/2)]], [ 

 

We could also view S as parametrized by: 

  x = u,  y = v,  z = u^2+v^2 

where u^2+v^2 <= 4. 

 

This gives us the following orientations: 

 

> r := `<,>`(u, v, u^2+v^2); 1
 

(Typesetting:-mprintslash)([r := Vector[column]([[u], [v], [u^2+v^2]], [ 

> rU := diff(r, u); 1
 

(Typesetting:-mprintslash)([rU := Vector[column]([[1], [0], [2*u]], [ 

> rV := diff(r, v); 1
 

(Typesetting:-mprintslash)([rV := Vector[column]([[0], [1], [2*v]], [ 

> rUxrV := `&x`(rU, rV); 1
 

(Typesetting:-mprintslash)([rUxrV := Vector[column]([[-2*u], [-2*v], [1]], [ 

> rUxrVLength := `assuming`([sqrt(Typesetting:-delayDotProduct(rUxrV, rUxrV))], [u::real, v::real]); 1
 

(Typesetting:-mprintslash)([rUxrVLength := (1+4*u^2+4*v^2)^(1/2)], [(1+4*u^2+4*v^2)^(1/2)]) 

 

"Upward" orientation: 

 

> n := rUxrV/rUxrVLength; 1
 

(Typesetting:-mprintslash)([n := Vector[column]([[-2*u/(1+4*u^2+4*v^2)^(1/2)], [-2*v/(1+4*u^2+4*v^2)^(1/2)], [1/(1+4*u^2+4*v^2)^(1/2)]], [ 

 

"Downward" orientation: 

 

> -n; 1
 

(Typesetting:-mprintslash)([Vector[column]([[2*u/(1+4*u^2+4*v^2)^(1/2)], [2*v/(1+4*u^2+4*v^2)^(1/2)], [-1/(1+4*u^2+4*v^2)^(1/2)]], [ 

 

Let's graph S along with it's downward orientation. 

 

[You may ask, "What are those seq commands and all those complicated formulas for?" Well, 

seq is the sequence command. This allows us to plug in a sequence of values into a formula. 

The whole idea of those commands is to list off a bunch of sample normal vectors for our 

surface without having to list them individually.] 

 

> plotS := plot3d(r, u = -2 .. 2, v = -sqrt(4-u^2) .. sqrt(4-u^2), numpoints = 1000); -1
 

> plotn := seq(seq(arrow(subs({u = a, v = b*sqrt(4-a^2)/(4.01-a^2)}, r), subs({u = a, v = b*sqrt(4-a^2)/(4.01-a^2)}, -n), shape = arrow, color = black), b = -4+a^2 .. 4-a^2), a = -2 .. 2); -1
plotn := seq(seq(arrow(subs({u = a, v = b*sqrt(4-a^2)/(4.01-a^2)}, r), subs({u = a, v = b*sqrt(4-a^2)/(4.01-a^2)}, -n), shape = arrow, color = black), b = -4+a^2 .. 4-a^2), a = -2 .. 2); -1
plotn := seq(seq(arrow(subs({u = a, v = b*sqrt(4-a^2)/(4.01-a^2)}, r), subs({u = a, v = b*sqrt(4-a^2)/(4.01-a^2)}, -n), shape = arrow, color = black), b = -4+a^2 .. 4-a^2), a = -2 .. 2); -1
 

> display(plotS, plotn, orientation = [170, 60], scaling = constrained); 1
 

Plot 

 

Here is an ellipsoid with it's outward orientation. 

 

> a := 1; 1
 

(Typesetting:-mprintslash)([a := 1], [1]) 

> b := 2; 1
 

(Typesetting:-mprintslash)([b := 2], [2]) 

> c := 3; 1
 

(Typesetting:-mprintslash)([c := 3], [3]) 

> r := `<,>`(a*cos(theta)*sin(phi), b*sin(theta)*sin(phi), c*cos(phi)); 1
 

(Typesetting:-mprintslash)([r := Vector[column]([[cos(theta)*sin(phi)], [2*sin(theta)*sin(phi)], [3*cos(phi)]], [ 

> rTheta := diff(r, theta); 1; rPhi := diff(r, phi); 1
 

(Typesetting:-mprintslash)([rTheta := Vector[column]([[-sin(theta)*sin(phi)], [2*cos(theta)*sin(phi)], [0]], [ 

(Typesetting:-mprintslash)([rPhi := Vector[column]([[cos(theta)*cos(phi)], [2*sin(theta)*cos(phi)], [-3*sin(phi)]], [ 

> rCross := `&x`(rTheta, rPhi); 1; rCrossLength := `assuming`([simplify(sqrt(Typesetting:-delayDotProduct(rCross, rCross)))], [theta::real, phi::real]); 1; n := `assuming`([-simplify(rCross/rCrossLength...
rCross := `&x`(rTheta, rPhi); 1; rCrossLength := `assuming`([simplify(sqrt(Typesetting:-delayDotProduct(rCross, rCross)))], [theta::real, phi::real]); 1; n := `assuming`([-simplify(rCross/rCrossLength...
rCross := `&x`(rTheta, rPhi); 1; rCrossLength := `assuming`([simplify(sqrt(Typesetting:-delayDotProduct(rCross, rCross)))], [theta::real, phi::real]); 1; n := `assuming`([-simplify(rCross/rCrossLength...
rCross := `&x`(rTheta, rPhi); 1; rCrossLength := `assuming`([simplify(sqrt(Typesetting:-delayDotProduct(rCross, rCross)))], [theta::real, phi::real]); 1; n := `assuming`([-simplify(rCross/rCrossLength...
 

(Typesetting:-mprintslash)([rCross := Vector[column]([[-6*cos(theta)*sin(phi)^2], [-3*sin(theta)*sin(phi)^2], [-2*sin(theta)^2*sin(phi)*cos(phi)-2*cos(theta)^2*sin(phi)*cos(phi)]], [
(Typesetting:-mprintslash)([rCross := Vector[column]([[-6*cos(theta)*sin(phi)^2], [-3*sin(theta)*sin(phi)^2], [-2*sin(theta)^2*sin(phi)*cos(phi)-2*cos(theta)^2*sin(phi)*cos(phi)]], [
 

(Typesetting:-mprintslash)([rCrossLength := (9+27*cos(theta)^2-27*cos(theta)^2*cos(phi)^2-5*cos(phi)^2)^(1/2)*abs(sin(phi))], [(9+27*cos(theta)^2-27*cos(theta)^2*cos(phi)^2-5*cos(phi)^2)^(1/2)*abs(sin... 

(Typesetting:-mprintslash)([n := Vector[column]([[6*sin(phi)*cos(theta)/(9+27*cos(theta)^2-27*cos(theta)^2*cos(phi)^2-5*cos(phi)^2)^(1/2)], [3*sin(phi)*sin(theta)/(9+27*cos(theta)^2-27*cos(theta)^2*co...
(Typesetting:-mprintslash)([n := Vector[column]([[6*sin(phi)*cos(theta)/(9+27*cos(theta)^2-27*cos(theta)^2*cos(phi)^2-5*cos(phi)^2)^(1/2)], [3*sin(phi)*sin(theta)/(9+27*cos(theta)^2-27*cos(theta)^2*co...
(Typesetting:-mprintslash)([n := Vector[column]([[6*sin(phi)*cos(theta)/(9+27*cos(theta)^2-27*cos(theta)^2*cos(phi)^2-5*cos(phi)^2)^(1/2)], [3*sin(phi)*sin(theta)/(9+27*cos(theta)^2-27*cos(theta)^2*co...
 

> plotEllipsoid := plot3d(r, theta = 0 .. 2*Pi, phi = 0 .. Pi); -1
 

> plotEllipsoidOrientation := seq(seq(arrow(evalf(subs({theta = 1/5*p*Pi, phi = 1/10*q*Pi}, r)), evalf(subs({theta = 1/5*p*Pi, phi = 1/10*q*Pi}, n)), shape = arrow, color = black), p = 0 .. 10), q = 0 ....
plotEllipsoidOrientation := seq(seq(arrow(evalf(subs({theta = 1/5*p*Pi, phi = 1/10*q*Pi}, r)), evalf(subs({theta = 1/5*p*Pi, phi = 1/10*q*Pi}, n)), shape = arrow, color = black), p = 0 .. 10), q = 0 ....
plotEllipsoidOrientation := seq(seq(arrow(evalf(subs({theta = 1/5*p*Pi, phi = 1/10*q*Pi}, r)), evalf(subs({theta = 1/5*p*Pi, phi = 1/10*q*Pi}, n)), shape = arrow, color = black), p = 0 .. 10), q = 0 ....
plotEllipsoidOrientation := seq(seq(arrow(evalf(subs({theta = 1/5*p*Pi, phi = 1/10*q*Pi}, r)), evalf(subs({theta = 1/5*p*Pi, phi = 1/10*q*Pi}, n)), shape = arrow, color = black), p = 0 .. 10), q = 0 ....
 

> display(plotEllipsoid, plotEllipsoidOrientation, scaling = constrained, orientation = [145, 30]); 1
display(plotEllipsoid, plotEllipsoidOrientation, scaling = constrained, orientation = [145, 30]); 1
 

Plot 

>