next up previous
Next: About this document ... Up: lab_template Previous: lab_template

Subsections


MA 1024 Lab 3: Partial derivatives, directional
derivatives, and the gradient

Purpose

The purpose of this lab is to acquaint you with using Maple to compute partial derivatives, directional derivatives, and the gradient.

Getting Started

To assist you, there is a worksheet associated with this lab that contains examples. You can copy that worksheet to your home directory with the following command, which must be run in a terminal window, not in Maple.

cp ~bfarr/Pardiff_start.mws ~

You can copy the worksheet now, but you should read through the lab before you load it into Maple. Once you have read to the exercises, start up Maple, load the worksheet Pardiff_start.mws, and go through it carefully. Then you can start working on the exercises.

Background

For a function $f(x)$ of a single real variable, the derivative $f'(x)$ gives information on whether the graph of $f$ is increasing or decreasing. Finding where the derivative is zero was important in finding extreme values. For a function $F(x,y)$ of two (or more) variables, the situation is more complicated.

Partial derivatives

A differentiable function, $F(x,y)$, of two variables has two partial derivatives: $\partial F /\partial x$ and $\partial F /\partial
y$. As you have learned in class, computing partial derivatives is very much like computing regular derivatives. The main difference is that when you are computing $\partial F /\partial x$, you must treat the variable $y$ as if it was a constant and vice-versa when computing $\partial F /\partial
y$.

The Maple commands for computing partial derivatives are D and diff. The Getting Started worksheet has examples of how to use these commands to compute partial derivatives.

Directional derivatives

The partial derivatives $\partial F /\partial x$ and $\partial F /\partial
y$ of $F$ can be thought of as the rate of change of $F$ in the direction parallel to the $x$ and $y$ axes, respectively. The directional derivative $D_{\mathbf{u}}F(\mathbf{p})$, where $\mathbf{u}$ is a unit vector, is the rate of change of $F$ in the direction $\mathbf{u}$. There are several different ways that the directional derivative can be computed. The method most often used for hand calculation relies on the gradient, which will be described below. It is also possible to simply use the definition

\begin{displaymath}D_{\mathbf{u}}F(\mathbf{p}) = \lim_{h \rightarrow 0}
\frac{F(\mathbf{p}+h\mathbf{u}) - F(\mathbf{p})}{h} \end{displaymath}

to compute the directional derivative. However, the following computation, based on the definition, is often simpler to use.

\begin{displaymath}D_{\mathbf{u}}F(\mathbf{p}) = \left. \frac{d}{dt}
F(\mathbf{p}+t\mathbf{u}) \, \right\vert _{t=0} \end{displaymath}

One way to think about this that can be helpful in understanding directional derivatives is to realize that $\mathbf{p}+t\mathbf{u}$ is a straight line in the $x,y$ plane. The plane perpendicular to the $x,y$ plane that contains this straight line intersects the surface $z =
F(x,y)$ in a curve whose $z$ coordinate is $F(\mathbf{p}+t\mathbf{u})$. The derivative of $F(\mathbf{p}+t\mathbf{u})$ at $t=0$ is the rate of change of $F$ at the point $\mathbf{p}$ moving in the direction $\mathbf{u}$.

Maple doesn't have a simple command for computing directional derivatives. There is a command in the tensor package that can be used, but it is a little confusing unless you know something about tensors. Fortunately, the method described above and the method using the gradient described below are both easy to implement in Maple. Examples are given in the Getting Started worksheet.

The Gradient

The gradient of $F$, written $\nabla F$, is most easily computed as

\begin{displaymath}\nabla F(\mathbf{p}) = \frac{\partial F}{\partial x}(\mathbf{...
...thbf{i} + \frac{\partial F}{\partial y}(\mathbf{p}) \mathbf{j} \end{displaymath}

As described in the text, the gradient has several important properties, including the following.

Maple has a fairly simple command grad in the linalg package (which we used for curve computations). Examples of computing gradients, using the gradient to compute directional derivatives, and plotting the gradient field are all in the Getting Started worksheet.

Exercises

  1. Consider the following function.

    \begin{displaymath}G(x,y) = \exp(-x^2)\cos(y))\end{displaymath}

    First, plot the graph of this function over the domain $-2 \leq x
\leq 2$ and $0 \leq y \leq 2\pi$ using the plot3d command. Then use the contourplot command to generate a contour plot of $G$ over the same domain.

  2. Compute the two first order partial derivatives of the function $G$ in the first exercise. You may use either the D or diff commands.

  3. Consider again the function $G$ from the first exercise. Using either method from the Getting Started compute the directional derivative of $G$ at the point $x=1$, $y= \pi$ in the three directions below. You may want to put an evalf command on the outside to get numerical values.
    1. $\mathbf{u} = \langle \cos(3 \pi/4), \sin(3 \pi/4) \rangle$
    2. $\mathbf{u} = \langle 1, 0 \rangle$
    3. $\mathbf{u} = \langle 0, 1 \rangle$

  4. Using the method from the Getting Started worksheet, plot the gradient field and the contours of $G$ on the same plot. Use the same domain of $-2 \leq x
\leq 2$ and $0 \leq y \leq 2\pi$. Can you use this plot to explain the values for the directional derivatives you obtained in the previous exercises? By explaining the values, I only mean can you explain why the values were positive, negative, or zero in terms of the contours and the gradient field?


next up previous
Next: About this document ... Up: lab_template Previous: lab_template
William W. Farr
2001-11-25