\magnification=\magstep1
\centerline{Mathematics 241 -- Multivariable Calculus}
\centerline{Lab Day 3 -- Vector Fields and Flow Lines}
\centerline{October 16, 2007}
\bigskip
\noindent
{\it Background and Goals}
\bigskip
A {\it vector field} is a vector-valued function on (a 
subset of) ${\bf R}^2$ or ${\bf R}^3$:
$$
\eqalign{
F: X \subseteq {\bf R}^2 & \to  {\bf R}^2\ {\rm or}\cr
F: X \subseteq {\bf R}^3 & \to  {\bf R}^3.         \cr
}
$$
We can visualize a vector field in the plane, for instance,
by drawing the vector $F(x,y)$ placing its tail at the 
point $(x,y)$ for all $(x,y) \in X$, or perhaps for 
the points in some finite subset of $X$ such as points
on a rectangular grid (this will help produce a more
understandable picture!)  Something similar can be 
done in ${\bf R}^3$ as well.  We will use Maple
today to see what a few of these look like and then
investigate what are called {\it flow lines} of vector 
fields.
\bigskip
\noindent
{\it A worked example}
\bigskip
We will be using two new Maple commands today that are
contained in external packages.  You will need to begin
by entering the following commands to load these
packages:
\medskip
\centerline{\tt with(plots):}
\centerline{\tt with(DEtools):}
\medskip
\noindent
(The colon at the end {\it suppresses the output} from the 
command, which is a list of all the procedures in the packages.
There are quite a few(!))

The command for plotting a vector field in the plane is
called {\tt fieldplot}.  To generate a plot of $F(x,y) = (x - 2y, 2x + y)$
we will use the following:
\medskip
\centerline{\tt fieldplot([x - 2*y, 2*x + y],x=-3..3,y=-3..3,arrows=SLIM,}
\centerline{\tt color=red,axes=boxed,fieldstrength=log);}
\medskip
\noindent
(this should all be entered on one input line in Maple; it's broken over two
lines here for typographical reasons).  Notes:  The $x$- and $y$- ranges
specify the portion of the plane that will be plotted.  The stuff after 
that specifies how the vectors in the vector field will be drawn, their color, 
the placement of the axes in the plot, and how the lengths of the arrows will be
shown.   Type in the command and examine the plot that is produced.
Vector fields are used to represent things like:
\medskip
\item{$\bullet$} the velocity vectors at each point in a fluid flow, or
\item{$\bullet$} the force vectors at each point due to some force
(e.g. gravitational force exerted by a mass placed somewhere in space).
\medskip
\noindent
Imagine a fluid flowing in the plane with velocity at each point given 
by the vector field you just plotted.  If we dropped a small, light 
object into the fluid at a particular point, where would the fluid carry it?  
For instance, try to visualize what would happen if the object started
at the location $(-0.2,-0.2)$ and it ``{\it goes with the flow}'' described
by the vector field. 

The path followed here would be an example of what is called a {\it flow line}
for the vector field.  By definition, a flow line of a vector field $F$
is a parametric curve
$\alpha(t) = (x(t),y(t))$ such that at each point on the curve, the tangent
vector to the curve {\it is the vector from the vector field $F$ at that point}.
In equations, this says:
$$\alpha'(t) = (x'(t),y'(t)) = F(x(t),y(t)) = (x(t) - 2y(t), 2x(t) + y(t))$$
for all $t$ in some interval in ${\bf R}$.  This vector equation
is equivalent to the following system of {\it differential 
equations} for the $x$- and $y$-components of the flow line:
$$\eqalign{
x'(t) &= x(t) - 2y(t)\cr
y'(t) &= 2x(t) + y(t)\cr}$$

We will use Maple now to see more precisely what the flow line starting at
$(-0.2,-0.2)$ looks like.  First enter the specification for the differential
equations as above in Maple format:
\medskip
\centerline{\tt des := [diff(x(t),t) = x(t) - 2*y(t),diff(y(t),t) = 2*x(t) + y(t)];}
\medskip
\noindent
Then the following command (from the {\tt DEtools} package loaded above) 
will draw the flowline (superimposed on another picture of the vector field,
for comparison):
\medskip
\centerline{\tt DEplot(des,[x(t),y(t)],t=0..4,[[x(0)=-0.2,y(0)=-0.2]],}
\centerline{\tt x=-3..3,y=-3..3,linecolor=black);}
\medskip
\noindent
(Again, type this all in one one input line).   Note the format of the 
command:  First the differential equations, then {\tt [x(t),y(t)]}, then 
the range of $t$ values that will be plotted on the flow line, then 
the ``initial conditions'' -- the starting point of the flow line, then 
the ranges of $x$- and $y$-values, then options to control the plotting.
You can also plot several flow lines together if you want by including
several initial conditions.  For instance, try changing that part of the 
command above to:
\medskip
\centerline{\tt [[x(0)=-0.2,y(0)=-0.2],[x(0) = -1, y(0) = -2]]}
\medskip
\noindent
to plot two flow lines together with the vector field.  
\bigskip
\noindent
{\it Lab Questions}
\bigskip
\noindent
A.  
\item{1)}  Following the worked example above, using the {\tt fieldplot}
command, plot the vector field
$F(x,y) = (\sin(x + y),\cos(x - y))$ on the rectangle with $x = 0 .. 2\pi$  ({\tt 2*Pi}
in Maple), and $y = 0 .. 2\pi$.  
\item{2)}  Examine your plot, and describe in words what the flow lines
starting from the points $(1,1)$, $(1,6)$, and $(4,3)$ appear to be doing.
\item{3)}  Then, use the {\tt DEplot} command to check your intuition
about the flow lines.  Did they do what you expected? 
\bigskip
\noindent
B.  Repeat part A, but using the vector field $G(x,y) = (x - 3y, 3x - y)$
on the rectangle with $x = -3..3$, $y = -3..3$.  In part 2, use the points
$(1,0),(-1,-1),(0,1)$.
\bigskip
\noindent
Maple can also plot 3D vector fields using another command called
{\tt fieldplot3d}.  The format is similar to the {\tt fieldplot}
command used above, but now you must specify three component functions
in the vector field, and give $x$-, $y$-, and $z$-ranges for the plotting.
\bigskip
\noindent
C.  Now we move up one dimension(!)
\item{1)}  Let $H$ be the vector field on ${\bf R}^3$ defined by
$$H(x,y,z) = \left({-x \over (x^2 + y^2 + z^2)^{3/2}}, {-y\over (x^2 + y^2 + z^2)^{3/2}},
{-z \over (x^2 + y^2 + z^2)^{3/2}}\right)$$
(note this is only defined when $(x,y,z) \ne (0,0,0)$).
Show (by hand, not using Maple), that at each point $(x,y,z)$,]
the vector $H(x,y,z)$ has magnitude 
inversely proportional to the square of 
the distance from $(x,y,z)$ to $(0,0,0)$.  Also show that
$H(x,y,z)$ is directed back toward $(0,0,0)$ from the point $(x,y,z)$.
(This says $H$ is similar to the gravitational force field exerted by 
a mass located at the origin).  
\item{2)}  Plot $H$ using the following Maple commands:
\medskip
\centerline{\tt r:=sqrt(x\^{}2 + y\^{}2 + z\^{}2);}
\centerline{\tt H:=[-x/r\^{}3,-y/r\^{}3,-z/r\^{}3];}
\centerline{\tt fieldplot3d(H,x=-2..2,y=-2..2,z=-2..2,fieldstrength=log,color=red,}
\centerline{\tt arrows=SLIM,axes=boxed,grid=[5,5,5]);}
\medskip
\item{3)}  What would the flow lines for this vector field look like?
\bigskip
\noindent
D.  Generate a 3D plot of the vector field $K(x,y,z) = (-y,x,1)$
in the rectangular solid $x = -2..2$, $y = -2..2$, $z = -5 .. 5$.  
Use the same options as in question C.  What would the flow
lines for this vector field look like?  Careful: there are
two different cases!  Find an explicit parametrization of the flow 
line starting from $(1,0,0)$.
\bye
