Spherical-Coordinate Plotting with Maple

The interactive version of this worksheet is in the Math 210 folder in the Workspace volume in MSB 203 (g3server). For instructions on accessing the class folder remotely, see the Space Curves worksheet.

1. Using the basic sphereplot command . Maple's plots library has a command sphereplot to plot surfaces whose spherical-coordinate equations have the form = f ( , ) . The syntax of the basic command is

sphereplot( f( , ), = .. , = .. ) ;

As was true of
cylinderplot , this basic command handles spherical-coordinate equations that are solvable for the radial variable Ñ in this case, Ñ and are swept out as the angles and vary over a "spherical-coordinate rectangle" [ , ] ´ [ , ] in the -plane. It thus can plot only one of the three basic equations coordinate variable = constant , namely the sphere = k. The next routine illustrates this for the case k = 4 . (The condition scaling = constrained appears because on most monitors the default plot of the sphere appears squashed.) As usual, execute the routine by placing the cursor after the last semicolon and hitting the Enter key.

> with (plots):
sphereplot (4, theta = 0..2*Pi, phi = 0..Pi, axes = boxed, scaling = constrained);

Unlike the cylindrical-coordinate system Ñ one of whose coordinates is the standard Cartesian
z Ñ the spherical-coordinate system is completely non-rectangular. Even so, it is often helpful to include plots of the three Cartesian coordinate axes in spherical-coordinate figures. The following routine generates such a figure for the sphere = 4. Execute it to see what the coordinate axes add.

> with (plots):
surf := sphereplot (4, theta = 0..2*Pi, phi = 0..Pi, axes = boxed, scaling = constrained):
xaxis := spacecurve([t, 0, 0, t = -5..6, color = magenta]) :
yaxis := spacecurve([0, t, 0, t = -5..6, color = magenta]) :
zaxis := spacecurve([0, 0, t, t = -5..6, color = magenta]) :
labx := textplot3d([6.1, 0, -.2, `x`], color = magenta):
laby := textplot3d([0,6.1, -.2, `y`], color = magenta):
labz := textplot3d([0, 0, 6.1, `z`], color = magenta):
display(surf, xaxis, yaxis, zaxis, labx, laby,labz);

The basic version of
sphereplot is powerful enough to give useful plots of many simple regions.

Example 1 . Plot the region E between the two spheres and .

Solution. The region is easy to visualize, and to plot if we restrict the angle t o the range [0, ¹], so that removal of the (hidden) sphere of smaller radius does not eliminate it from view! The following routine is just a slight modification of the last one.

> with (plots):
surf1 := sphereplot (2, theta = 0..Pi, phi = 0..Pi, axes = boxed, scaling = constrained, color = red):
surf2 := sphereplot (3, theta = 0..Pi, phi = 0..Pi, axes = boxed, scaling = constrained):
xaxis := spacecurve([t, 0, 0, t = -2..3.5, color = magenta]) :
yaxis := spacecurve([0, t, 0, t = -2..3.5, color = magenta]) :
zaxis := spacecurve([0, 0, t, t = -2..3.5, color = magenta]) :
labx := textplot3d([3.6, 0, -.2, `x`], color = magenta):
laby := textplot3d([0,3.6, -.2, `y`], color = magenta):
labz := textplot3d([0, 0, 3.6, `z`], color = magenta):
display(surf1, surf2, xaxis, yaxis, zaxis, labx, laby,labz);

Note that an arrow (like the x -axis) shot radially outward from the origin enters the region E by passing through the red sphere of radius 2, and then exits E through the sphere of radius 3. (This kind of observation later leads immediately to correct limits of integration!)

2. More general regions . Again just as for the cylinderplot command, Maple's sphereplot command Ñ in a more general form Ñ can plot surfaces whose equations are not of the basic form = f ( , ) . Once again, the syntax of the extended sphereplot command requires specifying the formulas for all three variables , and . [ Aside : Unfortunately, like Mathematica, Maple has a non-standard aspect to this: it expects those variables to appear in an order that reverses the normal order of and : , , . This amounts to a decision by Maple's programmers to prefer the Jacobian determinant of the spherical-coordinate transformation to be rather than the standard ; the reasons for such a choice are not clear. In anticipation of this, notice that above in the basic command, the ranges occur in the order first of and then of .] With u and v as generic symbols for the independent spherical-coordinate variables, the syntax for the extended sphereplot command takes the form

sphereplot( [ , , ], u = .. , v = .. ) ;

The next example illustrates the usefulness of the extended
sphereplot command by revisiting the first example of the Cylindrical Coordinate document.

Example 2
. Plot the region E above the graph of z = and below the graph of = 4.

Solution
. The sphere of course has the simple spherical-coordinate equation = 2. What is the spherical-coordinate equation of the upper half of the cone z = ? Recall that

z = cos

and
= r (of cylindrical Ñ or polar Ñ coordinates). In deriving the formulas for changing coordinates from spherical to rectangular coordinates, a key relation is

r = sin .

The equation
z = r of the cone thus transforms to

cos = sin Þ 1 = tan Þ = .

The following routine generates a plot of the region E without the need Ñ which arose in plotting E via cylindrical coordiantes Ñ to determine algebraically the curve of intersection of the sphere = 2 and the cone = . Experiment by rotating the default plot to produce a good view.

> with (plots):
surf1 := sphereplot (2, theta = 0..Pi, phi = 0..Pi/2, axes = boxed, color = red):
surf2 := sphereplot ([rho, theta, Pi/4], rho = 0..2, theta = 0..Pi):
xaxis := spacecurve([t, 0, 0, t = -2..2.5, color = magenta]) :
yaxis := spacecurve([0, t, 0, t = -2..2.5, color = magenta]) :
zaxis := spacecurve([0, 0, t, t = -1..2.5, color = magenta]) :
labx := textplot3d([2.6, 0, -.2, `x`], color = magenta):
laby := textplot3d([0,2.6, -.2, `y`], color = magenta):
labz := textplot3d([0, 0, 2.6, `z`], color = magenta):
display(surf1, surf2, xaxis, yaxis, zaxis, labx, laby,labz, scaling = constrained);

>

An arrow shot radially outward from the origin through
E emerges from the sphere = 2 . As with cylindrical coordinates, such observations later are the key to determining correct limits in evaluating multiple integrals over regions like E that have convenient spherical-coordinate descriptions.