Maple Lab 2 (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!
| > |
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.
| > |
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
![]()
We will be exploring Chapter 14 material using Maple. Specifically, we will be looking at:
multivariable scalar valued functions, level surfaces, partial derivatives, the gradient operator, mins/maxs & Lagrange multipliers
We have all ready seen how to graph functions of two variables:
using the
command and how to graph level
surfaces:
using the
command. Let's look at a command to draw level curves.
(The "contours" option tells Maple how many level curves to draw.)
First, we will define our function:
.
| > | ![]() |
![]()
![]()
![]()
| > |
The
command draws the level curves in 3D. The "filled=true" option tells Maple
to fill in the surface in between the level curves.
| > |
Let's draw a vector located at the point
which points in the gradient direction ("up-hill")
for this particular surface. To do so we need to use the gradient command.
| > |
The "Gradient" command spits out a "VectorField" object. We need to find the gradient's value
at the point
so we need the "evalVF" (evaluate vector field) command.
| > |
Putting a plot of this vector together with the contour plots gives us the following:
| > |
| > |
| > |
We can use Maple to compute directional derivatives. The "DirectionalDiff" command accepts
a function and a vector direction -- this vector does not need to be normalized, Maple will do
that for you.
Let's compute the directional derivative of our function at the point
in the
direction
using the formula for the directional derivative
and then using the built-in function.
| > |
| > |
| > |
Note: If we wished to dot and then evaluate, we must turn
into a vector field and substitute.
| > |
Now let's use the built-in function.
| > |
Remember that the gradient operator can also be used to find normal vectors for the tangent
planes of level curves. Let's graph the hyberboloid of one sheet
together
with its tagent plane and normal line at the point
.
First, notice that this point is on the surface:
| > | ![]() |
![]()
![]()
| > |
Now we will generate the normal vector at the point
.
| > |
Next, we need equations for the tangent plane and the normal line.
| > |
| > |
Now let's make our plots and display them together.
| > |
| > |
| > |
| > |
Now let's redo the minimum distance problem from class using Maple techniques.
12.7 #40) Find the points on the level surface
which are closest to the origin.
Let's begin with a graph of this surface.
| > |
| > |
From the graph we can see that the problem should have FOUR solutions.
We need to find a function describing the distance squared (to make things look nicer)
from the surface to the origin. Then we must
compute some partial derivatives, find
critical points, and test them.
Note: Minimizing the distanced squared is the same as minimizing the distance.
| > |
| > |
| > |
| > |
| > |
| > |
| > |
| > |
Notice that the mixed partials are the same:
| > |
Let's find the critial points.
| > |
![]()
Note: "RootOf(
)" means the number
which is a solution of
this means
or
. So (as in class) we actually have FOUR solutions!
| > |
The above graph shows that
has TWO
-intercepts.
Now we will construct the "D" operator which appears in our critical point test.
(We can't use the name "D" itself -- Maple's all ready using that for something.)
| > |
Now we plug in our critical points and see what we have.
| > |
| > |
Therefore, the first critical point is a local minimum.
Now we check the second point.
| > |
| > |
Therefore, both points are local minima.
We get that the surface is closest to the origin when...
| > |
and
| > |
Next, let's solve the problem again. But this time we'll use Lagrange multipliers.
Let's identify our objective function
(in this case the distance from
the origin squared) and our constraint
(in this case the level surface
defined by
.
| > |
| > |
| > |
| > |
Next, we need to compute the gradient of
and the gradient of
to find
our system of equations.
| > |
| > |
| > |
We can rip off the components of each side of the vector equation by using
something like this...
| > |
But it's just easier to compute the gradients one component at a time (using
the definition of the gradient operator) and construct our equations in that
manner.
| > |
| > |
| > |
Our last equation is given by the constraint.
| > |
Now we solve.
| > |
![]()
![]()
![]()
| > |
| > |
Looking carefully, you will notice that the answers given by this method are
the same as given by the last method. Evaluating our objective function at
these points tells us that the minimum distance to the origin is about 2.87.
| > |