\documentclass{article}
\usepackage{graphicx}

\def\R{{\mathchoice{\rm I\hskip-.2em R}{\rm I\hskip-.2em R}
{\rm I\hskip-.15em R}{\rm I\hskip-.1em R}}}
\setlength{\oddsidemargin}{0in} \setlength{\evensidemargin}{0in}
\setlength{\textwidth}{6.5in} \setlength{\textheight}{8.5in}
\setlength{\topmargin}{0in}
\setlength{\parindent}{0mm}

\title{Lab 5:  Multivariate Calculus}
\author{Your Names Here}

\begin{document}

\maketitle

Since we are running a bit short of time for this lab, this lab will consist
of answering several questions from Calculus III.  Unlike previous labs,
in this lab, you may simply write a short answer for each question in
LaTeX.  You should use figures where appropriate.

{\bf NOTE:}  Because of the 3-d graphics, please be sure you are running 
Maple 12 and not Maple 13.

{\bf NOTE:}  You may use this document as a starting point, but remove
everything you don't need.

\subsection*{Maple Commands, part I:} 
In this lab you will need to use the Maple commands for plotting
graphs, level curves and gradient vector fields. To load these commands, begin by typing:
\begin{verbatim}
with(plots):
\end{verbatim}
Recall that the command for plotting surfaces is \verb+plot3d+:
\begin{verbatim}
plot3d(x^2+y^2,x=-2..2,y=-2..2);
\end{verbatim}
The contourplot command is used to plot level curves:
\begin{verbatim}
contourplot(x^2+y^2,x=-2..2,y=-2..2,contours=30,scaling=constrained);
\end{verbatim}

The option {\tt contours=30} tells Maple to plot 30 level curves. Finally, the 
\verb+gradplot+ command
is used to plot the gradient vector field $\nabla f(x, y) $ of a function $z=f(x, y)$.
\begin{verbatim}
gradplot(x^2+y^2,x=-2..2,y=-2..2,scaling=constrained,arrows=slim);
\end{verbatim}

Use the display command to view the level curves and gradient vector field on the same
plot.
\begin{verbatim}
plot1:=contourplot(x^2+y^2,x=-2..2,y=-2..2,contours=30,scaling=constrained):
plot2:=gradplot(x^2+y^2,x=-2..2,y=-2..2,scaling=constrained,arrows=slim):
display(plot1,plot2);
\end{verbatim}

Notice that the gradient vectors are perpendicular to the level curves, as expected.
\subsection*{Lab Questions, Part I}
\begin{enumerate}
\item  Consider the function $f(x, y) = x^3-x^2-3x+8y-y^3+xy$ on the domain 
$[-3, 3]\times[-3, 3]$.
\begin{itemize}
\item Plot its graph, level curves, and gradient vector field on this domain. Plot the level
curves and gradient vector field together.  Discuss how we might find and classify 
the critical points of $f$ using this graph.
\item  Algebraically find and classify all of the
critical points of $f$ using the second derivative test, if it can
be applied.  
\end{itemize}
\item Same as Question 1, but using $g(x,y)=y^2+3x-x^3$.
\end{enumerate}

\subsection*{Maple Commands, Part II}

Double integrals are computed by iterating a single integral.  For example
(white space included for readability only):
$$
\int_0^3\int_x^4xy^2\,dy\,dx \quad \mbox{ is computed as }\quad 
\verb+int( int(x*y^2, y=x..4), x=0..3);+
$$
Parametric curves in three dimensions are plotted using the {\tt spacecurve}
command.  For example,
\begin{verbatim}
x:=2*sin(t);   y:=3*cos(t);  z:=1-sin(3*t);
spacecurve([x,y,z],t=0..15)
\end{verbatim}
Surfaces can also be parameterized.  They are mappings of the plane into
three dimensions.  Examples and the plots:

\begin{itemize}
\item If $z=f(x,y)$, we can write $x=u$, $y=v$, $z=f(u,v)$ to get three
functions of $(u, v)$.  For example, if $z=x^2-y^2$, then we could parameterize
the surface and plot it as:
\begin{verbatim}
restart; with(plots):  #Clear everything out
x:=u; y:=v; z:=u^2-v^2;
plot3d([x,y,z],u=-1..2,v=-1..2);
\end{verbatim}

\item The following three equations will plot the surface of a sphere.  In 
this case, if we have a point on the surface of a sphere, $u$ is the angle
that point makes in the $xy-$plane, and $v$ is the angle the point makes
with the (positive) $z-$axis:
\begin{verbatim}
x=sin(v)*cos(u); y:=sin(v)*sin(u); z:=cos(v);
plot3d([x,y,z], u=0..2*Pi,v=0..Pi);
\end{verbatim}
Compare this to the plot of the sphere.  See if you can reason out why
this is so bad.
\begin{verbatim}
x:='x'; y:='y';
f:=sqrt(1-x^2-y^2);
plot3d({f,-f},x=-2..2,y=-2..2, scaling=constrained);
\end{verbatim}
\item A surface of revolution from Calc II can be parameterized in three dimensions.
If $y=f(x)$ and we rotate about the $x-$axis, then let $u$ be the parameter measuring
where we are on the $x-$axis, and $v$ is the angle of rotation.  The plane of rotation
is parallel to the $yz$ plane, and
$$
x=u \qquad y=f(u)\cos(v) \qquad z=f(u)\sin(v)
$$
For example, to rotate the curve
\begin{verbatim}
x:='x'; y:='y'; z:='z';
f:=2+sin(u)-cos(u); x:=u; y:=f*cos(v); z:=f*sin(v);
plot3d([x,y,z],x=0..11,v=0..2*Pi);
\end{verbatim}
To put a curve on the surface of your object, we recall that it is a mapping
from the real line into 3-d.  Therefore, if $u$ and $v$ are both
functions of time, then the plot above would be a curve and not a 
surface:
\begin{verbatim}
x:='x'; y:='y'; z:='z'; u:='u'; v:='v';
f:=2+sin(u)-cos(u); x:=u; y:=f*cos(v); z:=f*sin(v);
A:=plot3d([x,y,z],u=0..11,v=0..2*Pi);
u:=11*sin(t); v:=2*Pi*t;
B:=spacecurve([x,y,z],t=0..1,color=black, thickness=2);
display3d({A,B});
\end{verbatim}
\end{itemize}
\subsection*{Lab Questions, continued}
\begin{enumerate}
\item[3. ] Look up the definition of the center of mass of a lamina
that occupies a region $D$ with density function $\rho(x,y)$.  
Find the center of mass if 
$$
D=\left\{(x,y)\,|\,0\leq y\leq \sin(x), \; 0\leq x \leq \pi \right\}, \quad \rho(x,y)=xy
$$

\item[4. ] Given the surface represented by:
$$
x=2\cos(\theta)+r\cos(\theta/2) \quad y=2\sin(\theta)+r\cos(\theta/2) \quad z=r\sin(\theta/2)
$$
where $-1/2\leq r \leq 1/2$, and $0\leq \theta\leq 2\pi$, graph it, then put
an interesting curve on its surface and plot them together (be creative!).
\item[5. ] We're told that the surface area given by a surface parameterized
by 
$$
{\mathbf r}(u,v)=x(u,v){\mathbf i}+y(u,v){\mathbf j} +z(u,v){\mathbf k}
$$
for $(u,v)\in D$ is given by:
$$
A(s)=\int \int_D |{\mathbf r}_u\times {\mathbf r}_v|\,dA
$$
Plot the surface defined by:
$$
x=(1-u)(3+cos(v))cos(4\pi u) \quad
y=(1-u)(3+cos(v))sin(4 \pi u) \quad
z=3u+(1-u)\sin(v)
$$
where $0\leq u \leq 1$ and $0\leq v \leq 2\pi$.  Now compute
a numerical approximation for the double integral representing
the surface area.
\end{enumerate}
\end{document}