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);
> diff(p,x);
> diff(p,y);
> 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);
> diff(f(x,y),x);
> D[1](f);
> D[2](f);
> D[1,1](f);
> D[1,2](f);
> 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)=x2+xy+y2, then
In Maple, you can calculate gradients using the grad command in the linalg package.> 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]);
> subs({x=3,y=1},evalm(del_g));
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
The Maple command for the gradient extends to this situation as well.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)=x2+xy+y2, P = (1,2) and . Then we have
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));
> 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 gT(x,y,a,b) to have the form
gT(x,y,a,b) = Ax + By + C
which is the equation of a plane. Recall that the linear approximation of a scalar function satisfied the two conditionsBy 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);
William W. Farr