** Next:** About this document ...
**Up:** No Title
** Previous:** No Title

The purpose of this lab is to acquaint you with differentiating multivariable functions.

You are already familiar with the Maple `D` and `diff`
commands for computing derivatives. These same commands can be used to
compute partial derivatives. As you have already learned, the
`diff` command is for differentiating Maple expressions and the
`D` command operates on functions. Examples are given below.

First, we define an expression.

> p := x^2*sin(x*y);

These commands compute and .

> diff(p,x);

> diff(p,y);

Higher order deriviatives are specified just by adding more arguments. The following commands compute the mixed partial derivatives

> diff(p,x,y);

> diff(p,y,x);

The `D` command can be simpler to use in some cases. However,
it only works on functions and you have to remember that the output of
the `D` command is also a function. Here are some examples.

> f := (x,y) -> y*exp(x+y);

Here is computed using the

> diff(f(x,y),x);

And the same thing using the

> D[1](f);

Here is the command for

> D[2](f);

When you define a function of two or more variables in Maple, you always have to provide names for the independent variables, and order is important. In the case of the function

> D[1,1](f);

To obtain use the following command.

> D[1,2](f);

To obtain the expression corresponding to a partial derivative rather than the function, use the following syntax. You can also use this syntax to evaluate a partial derivative at a specific point.

> D[1,2](f)(x,y);

> D[1,2](f)(0,1);

**Definition 1**

Suppose that *f*(*x*,*y*) is differentiable at a point *P* (see the text). Then
the gradient of *f*, denoted , is the vector

For example, if *f*(*x*,*y*)=*x ^{2}*+

> with(linalg):

Warning: new definition for norm Warning: new definition for trace

> g := (x,y) -> x^2+x*y+y^2;

> del_g := grad(g(x,y),[x,y]);

Note that the argument of

> subs({x=3,y=1},evalm(del_g));

The evalm command is necessary when substituting into vectors. See what happens without it.

The definition is straightforward to generalize to functions of three
or more independent variables - you just have as many components as
the number of independent variables. That is, for *g*(*x*,*y*,*z*) you would
have

We know that is the instantaneous
rate of change of *f* in the direction of the unit vector and
that, similarly, is the instantaneous
rate of change of *f* in the direction of the unit vector .The gradient can be used to find the instantaneous rate of change in
other directions as follows.

**Definition 2**

Suppose that *f*(*x*,*y*) is differentiable at a point *P*. Then for an
arbitrary unit vector , the *directional derivative* of *f*
at *P* in the direction , denoted is

For example, let *g*(*x*,*y*)=*x ^{2}*+

In Maple, computing directional derivatives can be a little clumsy, because of the difficulties in substituting into the gradient. One way to calculate a directional derivative is shown below.

> with(linalg):

Warning: new definition for norm Warning: new definition for trace

> g := (x,y) -> x^2+x*y+y^2;

> del_g := grad(g(x,y),[x,y]);

> u := vector([1/2,sqrt(3)/2]);

> r := subs({x=1,y=2},evalm(del_g));

Again, note the

> innerprod(r,u);

In the case of a function from to , , we clearly have to do
something different because we have more than one independent
variable. As we will see below, it turns out that the linear
approximation is a function that is linear in each of the independent
variables. Thus, in the case of a function *g*(*x*,*y*), we would expect
the linear approximation at a point (*a*,*b*), denoted *g*_{T}(*x*,*y*,*a*,*b*) to
have the form

*g*_{T}(*x*,*y*,*a*,*b*) = *Ax* + *By* + *C*

By analogy, you might expect the linear approximation to *g*(*x*,*y*) at a
point (*a*,*b*) to satisfy the conditions

These turn out to be the correct conditions, and lead to the formula

(1) |

A Maple procedure called `TanPlane`
is available in the `CalcP` package.
`TanPlane` outputs an expression that can be plotted or otherwise
manipulated. For example, you might want to plot it together with the
original function as shown below.

> with(CalcP):

> h := (x,y) -> x^2+y^2+2;

> TanPlane(h(x,y),x=1,y=2);

> plot3d({h(x,y),TanPlane(h(x,y),x=1,y=2)},x=-5..5,y=-5..5);

- 1.
- Compute the first and second order partial derivatives of the function Use Maple to plot the function and its first order partial derivatives (not on the same plot).
- 2.
- In the previous lab, you learned how to use the
`contourplot`command. Can you use a contour plot of a function to obtain information about the gradient of the function? Illustrate your answer by providing a contour plot of a function of your own choosing on which you have drawn arrows at three points that represent the gradient. - 3.
- Find the equations of the tangent planes for the following
functions at the specified points. Plot the graph of the function and
the tangent plane on the same plot. Be sure to choose a viewpoint and
a domain that best illustrates the relationship between the function and the
tangent plane.
- (a)
*g*(*x*,*y*) =*x*-^{2}*y*at (1,-1).^{2}- (b)
- at .
- (c)
- at (0,1).

- 4.
- Suppose you had a function
*h*(*x*,*y*,*z*). What do you think would be the formula for the linear approximation to*h*(*x*,*y*,*z*) at a point (*a*,*b*,*c*)? Illustrate your answer by finding the linear approximation to at the point (3,1,2) and comparing the approximate values and the actual values at a few points near (3,1,2). - 5.
- Is there a way to use the tangent plane at a specific point to compute the directional derivative at that same point? Show at least one example to illustrate your answer.

11/28/1999