Maple Assignment 3 for Mathematics 210


# This worksheet is on PLOTTING SURFACES for Stewart 2nd Edition
# by Neil Berger
#
# This worksheet covers material from Stewart section 11.6: Quadratic Surfaces,
# 11.7:  Vector functions and Space Curves, with additional material from parametric
# representation of surfaces taken form section 14.6.
#
# Section 11.6: Quadratic Surfaces:
#
# Here we solve example problems in Stewart from page 677/1-16.
# Find the traces of the given surface in the planes x=k, y=k, z=k, identify
# the surface and sketch it.
# 1. x^2-y^2+z^2=1  Here we choose x = k =1, 2, 3, 4
> with(plots): setoptions3d(axes=NORMAL):
>          Equation := 2^k-y^2+z^2=1:
>   for k from 1 to 4 do
>          implicitplot(Equation, y=-10..10, z=-10..10, title =`x = `.k)  od:
# It is also possible to make an animation of this set of traces:
> for k from 1 to 6 do
>               Saveplot[k] := implicitplot(Euation, y=-10..10, z=-10..10)  od:
> display([seq(Saveplot[k], k=1..6) ], insequence=true);
# NOTE: To do another Equation one need only go back and click on the line in which
# "Equation" was defined, and change the Equation to something new.  Then, by
# stepping through the sequence again (by pressing RETURN), a whole new function
# will be displayed.
# Other sample problems from this section are:
# 2. x = y^2+z^2
# 3. 4*x^2+9*y^2+36*z^2 = 36.
# 4. 2*x^2+z^2=4
# See additional problems on page 677/ 5-16.
# Rather than plot the trace of these curves, one can plot the entire surface
> implicitplot3d(x^2-y^2+z^2=1,x=-1..1,y=-2..2,z=-5..5);
# It is easy to see that the traces gives a  much better understanding of the figure in
# many cases.
#
# Section 11.7: Vector Functions and Space Curves:
#
# It is easy to plot vector functions and space curves.   For example, to plot
# problem 5 on page 683: r[t] = [t^4+1,0,t] we use:
> r[t] := [t^4+1,0,t];
> spacecurve(r[t], t=0..5);
# Make sure you use the AXIS pull-down menu to get dfferent axes setup on the graph.  You may use the left
# mouse button to rotate the figure and then click the right mouse
# button outside of the bounding box to redraw the figure.
# The problems on 683,  1-10  can easily be graphed with these techniques.
#
#
# Section 12.1: Functions of Several Variables.
#
# Stewart motivates his treatment with the 3-D plots of many surfaces. For example the plots on page 715 figure
# 12.4 (which lies in the first octant)  can be recovered by:
> plot3d(max(6-3*x-2*y,0),x=0..2,y=0..3);
# Note that the max function gives the tilted plane as well as the plane z=0.
#
# The figure 12.6 is almost given by
#
> plot3d(4*x^2+y^2,x=-2..2,y=-4..4);
#
# The problem here is that maple uses a square grid to plot the figure.
# We can almost fix it by the following trick, which also plots a portion of the plane z=10:
> plot3d(min(4*x^2+y^2,10),x=-2..2,y=-4..4);
# For curves and contours we can use contourplot.
# For example 6 on page 718 we have:
> contourplot(sqrt(9-x^2-y^2),x=-2..2,y=-2..2);
# For example 7:
> contourplot(4*x^2+y^2,x=-1..1,y=-1..1);
# And a more striking example from page 720:
> contourplot(-x*y*exp(-x^2-y^2),x=-1..1,y=-1..1);
# The exercises on page 722 numbers 31-56 require the drawing of the level surfaces and  graphs of  various
# graphs.  In each case you should have maple plot the 3-D surface as well as the countour plot.
# e.g. 722/52: Draw the coutour plot of f(x,y) = y-cos(x)
> Graph:= y-cos(x);
> plot3d(Graph,x=-10..10,y=-10..10);
> contourplot(Graph,x=-10..10,y=-10..10);
# A selection of problems can be done by just changing the definition of Graph, and then running the previous three
# commands.
#
# We can also introduce here the representation of  a surface in terms of parameters.
# This is not explicitly covered in Stewart except briefly in section 14.6 (pp.889-890).
# In particular, the following problems appear in Stewart on page 896:
#
# In exercises 1-8 find the parametric representation for the surface:
# 1. The upper half of the ellipsoid 3*x^2+2*y^2+z^2=1
# 2. The part of the hyperboloid -x^2-y^2+z^2=1 that lies below the
# rectangle [-1,1] X [-3,3].
# 3. The part of the elliptic paraboloid y = 6-3*x^2-2*z^2 that lies to the right of the xz-plane.
# 4.  The part of the elliptic paraboloid x+y^2+2*z^2=4 that lies in front of the plane x=0.
# and so on.
#
# The point of this exercise is to develop geometrical intuation about the shapes and positions of surfaces in three
# dimensional space.
#
# Consider the equation  2*x^2 + 2*y^2 + 3*z^2=1 .  This represents a quadratic surface in three-dimensional
# space.  We wll use Maple to plot the surface:
#
# Since one usually plots functions and NOT equations, we can first translate this surface into a function.  We do
# this by solving for one of the variables, say z:
> Equation  := 2*x^2+2*y^2+3*z^2=1;
> Solution := solve(Equation,z);
# Two possible surfaces result.  We can plot them separately, or together.  The command to plot in 3-D is plot3d.
# If we needed help on this command we could use the command   ?plot3d.  Here we just forge ahead.  We plot the
# first of the two solutions.   Once the plot appears, you can rotate it and change the viewing angle by clicking and
# holding down the left mouse button, while moving  the mouse.  When you release the button,  and click the right
# mouse button outside of the box, the new graph will appear.
> plot3d(Solution[1],x=-1..1,y=-1..1);
# We now plot the second solution.
> plot3d(Solution[2],x=-1..1,y=-1..1);
# and both the top and the bottom:
> plot3d({Solution},x=-1..1,y=-1..1,axes=NORMAL);
# Some portions of the figure will be missing.  Why?  This has to do with the way in which Maple plots surfaces
# using a rectangular grid.  If we change the description of the surface to a PARAMETRIC representation, then
# Maple will give a better plot.  We need to use a two parameter representaion.  Here we use alpha and beta
# as the parameters:
> f := 2*x^2 = (cos(alpha)*cos(beta))^2;
> g:= 2*y^2 =(cos(alpha)*sin(beta))^2;
> h := 3*z^2=(sin(alpha))^2;
> f+g+h;
> simplify(");
# and we see that this is one possible representation of the surface.   We now plot the surface by first solving for
# x,y and z, and then taking a range of alpha and beta which covers the entire surface.
> solve(f,x);
# This gives two solutions, but by letting alpha range form 0 to 2*Pi we will get both.
> solve(g,y);
> solve(h,z);
# So, it is clear that by letting alpha range form 0 to 2*Pi and picking only the first solution we can get the proper
# surface.  Notice that for parametric plotting the argument is enclosed in [...] rather than {...}.
> plot3d([solve(f,x)[1],solve(g,y)[1],solve(h,z)[1]], alpha= 0..2*Pi, beta=0..Pi);
# We now do problem 2 page 896 of Stewart:
> Solution := solve(-x^2-y^2+z^2=1,z);
> plot3d(Solution[2], x=-1..1,y=-3..3);
# It is also possible to use the command implicitplot3d to get a complete picture of the
# same surface without going through the procedure of solving for a variable:
> implicitplot3d(-x^2-y^2+z^2=1,x=-1..1,y=-3..3,z=-3..3);

Back to Maple Assignment Cover Page