Maple Lab 3 (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 15 material using Maple. Specifically, we will be looking at: 

computing multiple integrals, plotting solids, and finding centroids. 

 

We have all ready seen how to graph functions of two variables: z = f(x, y) using the plot3d command. Now let's 

look at how we can use plot3d to graph "parametric surfaces". To get started let's look at some 2D examples. 

 

> f := proc (x) options operator, arrow; x^2 end proc; 1
 

(Typesetting:-mprintslash)([f := proc (x) options operator, arrow; x^2 end proc], [proc (x) options operator, arrow; x^2 end proc]) 

> f(x); 1
 

x^2 

> plot(f(x), x = -1 .. 2); 1
 

Plot 

So we have plotted part of a parabola. Now let's parametrize this curve. Parametrization can 

be very tricky in general, but in the case we are looking at a curve of the form: y = f(x) it's 

quite simple. Using t as our parameter, we simply choose: x = t and y = f(t). 

 

Now we can graph our piece of the parabola using parametric equations. 

 

> plot([t, f(t), t = -1 .. 2]); 1
 

Plot 

In much the same way, we can parametrize any surface of the form: z = f(x, y) using 

two parameters (say s and t) as follows: x = s, y = t, and z = f(s, t).  

 

We can plot these surfaces using plot3d either in the "old" way or the "new" (parametric) way. 

 

For Example: 

> f := proc (x, y) options operator, arrow; 4-1/8*x^2-1/8*y^2 end proc; 1
 

(Typesetting:-mprintslash)([f := proc (x, y) options operator, arrow; (VectorCalculus:-`+`)((VectorCalculus:-`+`)(4, (VectorCalculus:-`-`)((VectorCalculus:-`*`)((VectorCalculus:-`*`)(1, 1/8), x^2))), ...
(Typesetting:-mprintslash)([f := proc (x, y) options operator, arrow; (VectorCalculus:-`+`)((VectorCalculus:-`+`)(4, (VectorCalculus:-`-`)((VectorCalculus:-`*`)((VectorCalculus:-`*`)(1, 1/8), x^2))), ...
(Typesetting:-mprintslash)([f := proc (x, y) options operator, arrow; (VectorCalculus:-`+`)((VectorCalculus:-`+`)(4, (VectorCalculus:-`-`)((VectorCalculus:-`*`)((VectorCalculus:-`*`)(1, 1/8), x^2))), ...
 

> f(x, y); 1
 

4-1/8*x^2-1/8*y^2 

> plot3d(f(x, y), x = -5 .. 5, y = -5 .. 5); 1
 

Plot 

> plot3d([s, t, f(s, t)], s = -5 .. 5, t = -5 .. 5); 1
 

Plot 

 

It is also important to note that so far we have been plotting surfaces defined over a rectangle. 

In the example above we are graphing over the rectangle: Typesetting:-delayCrossProduct([-5, 5], [-5, 5]).  

 

Maple can handle plots defined over "type I" or "type II" regions. For example, let's graph 

f(x, y) = 4-1/8*x^2-1/8*y^2 over the region (inside  

a circle centered at the origin with radius 4). 

 

The region Ris both "type I" and "type II", let's consider it as "type II". We find bounds for x  

in terms of (diff(y(x), x))*s and then constant ybounds. 

 

> xBounds := solve(x^2+y^2 = 16, x); 1
 

(Typesetting:-mprintslash)([xBounds := (-y^2+16)^(1/2), -(-y^2+16)^(1/2)], [(-y^2+16)^(1/2), -(-y^2+16)^(1/2)]) 

> solve({xBounds}, y); 1
 

{y = 4}, {y = -4} 

 

So we get the bounds: -sqrt(-y^2+16) <= x and x <= sqrt(-y^2+16) and -4 <= y and y <= 4. 

 

> plot3d(f(x, y), x = -sqrt(-y^2+16) .. sqrt(-y^2+16), y = -4 .. 4, scaling = constrained, orientation = [50, 100]); 1
plot3d(f(x, y), x = -sqrt(-y^2+16) .. sqrt(-y^2+16), y = -4 .. 4, scaling = constrained, orientation = [50, 100]); 1
 

Plot 

Of course we can do far more with parametric plots. Consider the sphere centered at the origin with radius 5. 

In rectangular coordinates it is described by x^2+y^2+z^2 = 25, but in spherical coordinates we have 

the much simpler equation "rho = 5". Using these coordinates, we see that: 

 

x = 5*cos(theta)*sin(phi),   y = 5*sin(theta)*sin(phi),   and   z = 5*cos(phi)  where   0 <= theta and theta <= 2*Pi   and   0 <= phi and phi <= Pi. 

 

Let's plot our sphere using "parametric plot3d". 

 

> plot3d([5*cos(theta)*sin(phi), 5*sin(theta)*sin(phi), 5*cos(phi)], theta = 0 .. 2*Pi, phi = 0 .. Pi); 1
 

Plot 

 

Notice that this plot looks much nicer than what we got in previous labs using implicitplot3d! 

 

Let's use this new tool to plot the region of integration for problem #31 in section 15.7. 

 

In this problem we are supposed to rewrite the integral:  

as equivalent iterated integrals in the 5 other orders. 

 

We are integrating over the solid region bounded by  z = 0,  z = 1-y,   y = sqrt(x),  and  x = 0. 

 

[It turns out that the other bounds (the upper bounds on the outter two integrals): y = 1 and x = 1 

are extraneous. If we plot them along with the bounds listed above, they will just make it harder to 

"see" what's going on.] 

 

Let's simultaneously plot all of these surfaces and then make the proper restrictions to get a plot 

of our "mystery" solid. 

 

First, the two surfaces:  z = 0 and z = 1-y which make up the "bottom" and "top" of our solid. 

 

> bottom := plot3d([x, y, 0], x = 0 .. 1, y = 0 .. 1, color = blue); 1
 

bottom := INTERFACE_PLOT3D(MESH(Array( 1..25,1..25,1..3, [... unable to display content ...] ), COLOR(RGB, 0., 0., 1.00000000))) 

> top := plot3d([x, y, 1-y], x = 0 .. 1, y = 0 .. 1, color = green); 1
 

top := INTERFACE_PLOT3D(MESH(Array( 1..25,1..25,1..3, [... unable to display content ...] ), COLOR(RGB, 0., 1.00000000, 0.))) 

 

Next, the front and back. These surfaces should be of the form: x = g(y, z)(if we wanted to 

plot "sides", we should have surfaces of the form: y = h(x, z)). This means we should plot: 

x = 0(the back) and x = y^2 (the front -- we got this by solving y = sqrt(x) for x). 

 

> back := plot3d([0, y, z], y = 0 .. 1, z = 0 .. 1, color = red); 1
 

back := INTERFACE_PLOT3D(MESH(Array( 1..25,1..25,1..3, [... unable to display content ...] ), COLOR(RGB, 1.00000000, 0., 0.))) 

> front := plot3d([y^2, y, z], y = 0 .. 1, z = 0 .. 1, color = yellow); 1
 

front := INTERFACE_PLOT3D(MESH(Array( 1..25,1..25,1..3, [... unable to display content ...] ), COLOR(RGB, 1.00000000, 1.00000000, 0.))) 

> display({front, bottom, top, back}, axes = normal, labels = [x, y, z], orientation = [41, 64]); 1
display({front, bottom, top, back}, axes = normal, labels = [x, y, z], orientation = [41, 64]); 1
 

Plot 

 

From this we can see how to "cut off" irrelevant parts of our surfaces. 

 

> bottom2 := plot3d([x, y, 0], x = 0 .. 1, y = sqrt(x) .. 1, color = blue); 1
 

bottom2 := INTERFACE_PLOT3D(MESH(Array( 1..25,1..25,1..3, [... unable to display content ...] ), COLOR(RGB, 0., 0., 1.00000000)), AXESLABELS(x, y, ``)) 

> top2 := plot3d([x, y, 1-y], x = 0 .. 1, y = sqrt(x) .. 1, color = green); 1
 

top2 := INTERFACE_PLOT3D(MESH(Array( 1..25,1..25,1..3, [... unable to display content ...] ), COLOR(RGB, 0., 1.00000000, 0.)), AXESLABELS(x, y, ``)) 

> back2 := plot3d([0, y, z], y = 0 .. 1, z = 0 .. 1-y, color = red); 1
 

back2 := INTERFACE_PLOT3D(MESH(Array( 1..25,1..25,1..3, [... unable to display content ...] ), COLOR(RGB, 1.00000000, 0., 0.)), AXESLABELS(y, z, ``)) 

> front2 := plot3d([y^2, y, z], y = 0 .. 1, z = 0 .. 1-y, color = yellow); 1
 

front2 := INTERFACE_PLOT3D(MESH(Array( 1..25,1..25,1..3, [... unable to display content ...] ), COLOR(RGB, 1.00000000, 1.00000000, 0.)), AXESLABELS(y, z, ``)) 

> display({top2, back2, front2, bottom2}, axes = normal, labels = [x, y, z], orientation = [41, 64]); 1
display({top2, back2, front2, bottom2}, axes = normal, labels = [x, y, z], orientation = [41, 64]); 1
 

Plot 

 

Using this graph, we can better "see" how to write down the remaining 5 iterated integrals. 

 

Let's assume the function is f(x, y, z) = x^2+y*z and then compute all 6 iterated integrals. 

[If our answers are right, we should get the same result each time.] 

 

Let's "squash out" the z-direction and see what region in the xy-plane with which we are dealing. 

 

> plot3d([x, y, 0], x = 0 .. 1, y = sqrt(x) .. 1, axes = normal, orientation = [23, 37]); 1
 

Plot 

 

We begin by computing the triple integral in the original order:  

> int(int(int(x^2+y*z, z = 0 .. 1-y), y = sqrt(x) .. 1), x = 0 .. 1); 1
 

1/70 

 

Next:  

 

> int(int(int(x^2+y*z, z = 0 .. 1-y), x = 0 .. y^2), y = 0 .. 1); 1
 

1/70 

 

In the next two integrals we will place dx first, so let's see what region of the 

yz-plane we are dealing with when the x's are "squashed out". 

 

> plot3d([0, y, z], y = 0 .. 1, z = 0 .. 1-y, axes = normal); 1
 

Plot 

 

Next:  

 

> int(int(int(x^2+y*z, x = 0 .. y^2), y = 0 .. 1-z), z = 0 .. 1); 1
 

1/70 

 

Next:  

 

> int(int(int(x^2+y*z, x = 0 .. y^2), z = 0 .. 1-y), y = 0 .. 1); 1
 

1/70 

 

In the final two integrals we will place dy first, so let's see what region of the 

xz-plane we are dealing with when the y's are "squashed out". 

 

> plot3d([x, 0, z], x = 0 .. 1, z = 0 .. 1-sqrt(x), axes = normal, orientation = [50, 70]); 1
 

Plot 

 

Next:  

 

> int(int(int(x^2+y*z, y = sqrt(x) .. 1-z), x = 0 .. (-1+z)^2), z = 0 .. 1); 1
 

1/70 

 

Next:  

 

> int(int(int(x^2+y*z, y = sqrt(x) .. 1-z), z = 0 .. 1-sqrt(x)), x = 0 .. 1); 1
 

1/70 

 

We have seen how Maple can help us visualize 3D (and 2D) regions of integration. 

Now let's make Maple help us compute Jacobians and preform change of variables 

for multiple integrals. 

 

Let's make Maple compute the Jacobian for spherical coordinates. 

 

[The following command spits out a "Jacobian matrix" and the "Jacobian determinant". 

 We just need the latter. Since the command spits out a sequence of answers, we 

  put a sequence of labels on the left hand side of the assignment (i.e. "").] 

 

> M, J := Jacobian([rho*cos(theta)*sin(phi), rho*sin(theta)*sin(phi), rho*cos(phi)], [rho, theta, phi], 'determinant'); 1
M, J := Jacobian([rho*cos(theta)*sin(phi), rho*sin(theta)*sin(phi), rho*cos(phi)], [rho, theta, phi], 'determinant'); 1
 

(Typesetting:-mprintslash)([M, J := Matrix([[cos(theta)*sin(phi), -rho*sin(theta)*sin(phi), rho*cos(theta)*cos(phi)], [sin(theta)*sin(phi), rho*cos(theta)*sin(phi), rho*sin(theta)*cos(phi)], [cos(phi)...
(Typesetting:-mprintslash)([M, J := Matrix([[cos(theta)*sin(phi), -rho*sin(theta)*sin(phi), rho*cos(theta)*cos(phi)], [sin(theta)*sin(phi), rho*cos(theta)*sin(phi), rho*sin(theta)*cos(phi)], [cos(phi)...
(Typesetting:-mprintslash)([M, J := Matrix([[cos(theta)*sin(phi), -rho*sin(theta)*sin(phi), rho*cos(theta)*cos(phi)], [sin(theta)*sin(phi), rho*cos(theta)*sin(phi), rho*sin(theta)*cos(phi)], [cos(phi)...
 

 

Don't forget to simplify the Jacobian... 

 

> J := simplify(J); 1
 

(Typesetting:-mprintslash)([J := -sin(phi)*rho^2], [-sin(phi)*rho^2]) 

 

Let's compute the centroid of the "bumpy sphere" which is described by the 

equation rho = 1+1/5*sin(6*theta)*sin(5*phi) (in spherical coordinates). 

 

> bumpyRho := 1+1/5*sin(6*theta)*sin(5*phi); 1
 

(Typesetting:-mprintslash)([bumpyRho := 1+1/5*sin(6*theta)*sin(5*phi)], [1+1/5*sin(6*theta)*sin(5*phi)]) 

> plot3d([bumpyRho*cos(theta)*sin(phi), bumpyRho*sin(theta)*sin(phi), bumpyRho*cos(phi)], theta = 0 .. 2*Pi, phi = 0 .. Pi, numpoints = 5000); 1
plot3d([bumpyRho*cos(theta)*sin(phi), bumpyRho*sin(theta)*sin(phi), bumpyRho*cos(phi)], theta = 0 .. 2*Pi, phi = 0 .. Pi, numpoints = 5000); 1
 

Plot 

 

Looking at the sphere we might guess that the centroid is the origin. 

Let's verify this by computing some integrals. 

 

First, the volume of the interior Eof the bumpy sphere is given by:  

 

where diff(E(x), x) is the interior of the bumpy sphere described in spherical coordinates. 

 

Thus we have... 

> bumpyVolume := int(int(int(sin(phi)*rho^2, rho = 0 .. bumpyRho), theta = 0 .. 2*Pi), phi = 0 .. Pi); 1
bumpyVolume := int(int(int(sin(phi)*rho^2, rho = 0 .. bumpyRho), theta = 0 .. 2*Pi), phi = 0 .. Pi); 1
 

(Typesetting:-mprintslash)([bumpyVolume := 136/99*Pi], [136/99*Pi]) 

 

Next, we must compute the moments about the xy, xz, and yz planes. 

 

For example: 

 

(since z = rho*cos(phi) and the absolute value of the Jacobian is sin(phi)*rho^2). 

 

> Mxy := int(int(int(rho^3*cos(phi)*sin(phi), rho = 0 .. bumpyRho), theta = 0 .. 2*Pi), phi = 0 .. Pi); 1
Mxy := int(int(int(rho^3*cos(phi)*sin(phi), rho = 0 .. bumpyRho), theta = 0 .. 2*Pi), phi = 0 .. Pi); 1
 

(Typesetting:-mprintslash)([Mxy := 0], [0]) 

> Mxz := int(int(int(rho^3*sin(theta)*sin(phi)^2, rho = 0 .. bumpyRho), theta = 0 .. 2*Pi), phi = 0 .. Pi); 1
Mxz := int(int(int(rho^3*sin(theta)*sin(phi)^2, rho = 0 .. bumpyRho), theta = 0 .. 2*Pi), phi = 0 .. Pi); 1
 

(Typesetting:-mprintslash)([Mxz := 0], [0]) 

> Myz := int(int(int(rho^3*cos(theta)*sin(phi)^2, rho = 0 .. bumpyRho), theta = 0 .. 2*Pi), phi = 0 .. Pi); 1
Myz := int(int(int(rho^3*cos(theta)*sin(phi)^2, rho = 0 .. bumpyRho), theta = 0 .. 2*Pi), phi = 0 .. Pi); 1
 

(Typesetting:-mprintslash)([Myz := 0], [0]) 

 

Then the centroid is: (M[yz], M[xz], M[xy])/volume which is... 

 

> `<,>`(Myz, Mxz, Mxy)/bumpyVolume; 1
 

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

 

The origin...just as we suspected!