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

Subsections


MA 1024: 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. You can copy that worksheet to your home directory by copying the directory location below to your computer's Start menu search or in your Maple screen, go to File - Open, then paste the dirctory location in the dialogue box where it says file name.

\\storage.wpi.edu\academics\math\calclab\MA1024\Pardiff_grad_start_B19.mw

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 diff command can be used on both expressions and functions whereas the D command can be used only on functions. The commands below show examples of first order and second order partials in Maple.

> f := (x,y) -> x^2y^2-xy
> diff(f(x,y),x)
> diff(f(x,y),y,y)
> D[1](f)(x,y)
> D[2,2](f)(x,y)
Note in the above D command that the 1 in the square brackets means x and the 2 means y. The next example shows how to evaluate the mixed partial derivative of the function given above at the point $\displaystyle (-1,1)$.

> eval(diff(f(x,y),x,y),{x=-1,y=1})
> D[1,2](f)(-1,1)

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. For the function

    \begin{displaymath}f(x,y)= \frac{2x+2y+1}{x^2+y^2+1} \end{displaymath}

    a)
    Use the diff command to compute the two first order partial derivatives $\displaystyle \frac{\partial f}{\partial x}$ and $\displaystyle \frac{\partial f}{\partial y}$ in Maple and compare to the x and y components of the gradient of $f$.
    b)
    Use the D command to compute the two first order partial derivatives $\displaystyle \frac{\partial f}{\partial x}$ and $\displaystyle \frac{\partial f}{\partial y}$ at $P_0(1,1)$ and compare to the x and y components of $\nabla \mathbf{f}(1,1)$
    c)
    Find the z value at $P_0(1,1)$ and plot the level curve through $P_0$ using the 2D implicitplot command. Use plotting intervals $0 \leq x \leq 2$, $0 \leq y \leq 2$.
    d)
    Find the equation of the line tangent to the level curve at $P_0(1,1)$ and plot the tangent line and the gradient vector $\nabla \mathbf{f}(1,1)$ on the same graph as the level curve. What do you notice about the relationship between the gradient and the tangent line?

  2. For the same function $f(x,y)$
    a)
    Compute the directional derivative of $f$ at the point $\displaystyle (1,1)$ in each of the directions below. Explain what your results tell about the surface at that point in the given direction in terms of being positive, negative or zero. Be sure to use a unit vector in your calculation of the directional derivative.
    1. $\displaystyle \mathbf{u_1} = \langle 1, 1 \rangle$
    2. $\displaystyle \mathbf{u_2} = \langle -3, -4 \rangle$
    3. $\displaystyle \mathbf{u_3} = \langle -1, 1 \rangle$

    b)
    Plot the gradient field of $f$ over the intervals $0 \leq x \leq 2$ and $0 \leq y \leq 2$ using a $[20,20]$ grid and fieldstrength=fixed and plot each direction vector from above at the point $\displaystyle (1,1)$ on the same plot. Based on the relationship between the direction vector and the gradient, explain why the directional derivatives above were positive, negative or zero.

    c)
    Copy, paste and re-execute ONLY the fieldplot from above and delete the colon. Given what you know about the relationship between gradient vectors and direction of greatest rate of change, can you estimate the $(x,y)$ ordered pair where $f$ may have a local maximum? Explain.


next up previous
Next: About this document ... Up: lab_template Previous: lab_template
Dina J. Solitro-Rassias
2019-10-30