Laboratory 7
Partial Derivatives and Tangent Planes

Introduction

    In this lab we examine the notion of the partial derivatives of a function, and study them both symbolically and graphically. We also use partial derivatives to calculate the equations of tangent planes to surfaces.

Example 7.1, A Graphical Introduction to Partial Derivatives

    Let us consider a function f(x, y), say

f[x_, y_] := 4 - x + y - x^2 - y^2

We obtain the graph of this function on the region -3≤x≤3, -3≤y≤3 in the usual fashion.

Plot3D[f[x, y], {x, -3, 3}, {y, -3, 3}, BoxRatios {1, 1, 1}] ;

[Graphics:HTMLFiles/index_6.gif]

Note that we use the BoxRatios->{1,1,1} option to make sure that the graph has the same scale in each direction.

    Now suppose that we choose a specific value for y, say y = 0. We can then look at the function of one variable xf(x, 0). The graph of this function is the intersection of the three-dimensional graph and the plane y = 0. To obtain these graphs, we have defined a new command called YSlice.

YSlice[f_, ys_, {x, x0_, x1_}, {y, y0_, y1_}, {z, z0_, z1_}] := Module[{a, b, c, d}, a ... ;GraphicsArray[{c, d}], DisplayFunction$DisplayFunction, ImageSize600] ; ]

The that the first parameter is the function we wish to graph, while the second parameter is the fixed value of y whose slice we want, in our example y = 0. The remaining parameters are the x-range, y-range, and z-range of the plot. We now apply this command to the previous function f.

YSlice[f, 0, {x, -3, 3}, {y, -3, 3}, {z, -10, 10}]

[Graphics:HTMLFiles/index_19.gif]

On the left we have the three dimensional graph of f(x, y) together with the plane y = 0. On the right, we have the graph of the function z = f(x, 0). Looking at the function on the right, we might ask what is the derivative of this function that corresponds to a single value of x, say x = 0. To estimate the slope of this function from the graph at that point, we can zoom in at that point. To do so, we again call the function YSlice, changing repeatedly the range of values for x, y, and z as follows.

YSlice[f, 0, {x, -0.5, 0.5}, {y, -0.5, 0.5}, {z, 2.5, 5}]

[Graphics:HTMLFiles/index_29.gif]

Notice that we changed the range of values for z at the same time that we changed the range of values for x and y. In particular, we chose the range of values for z so that our graphs show the variation in the values of the function.

YSlice[f, 0, {x, -0.1, 0.1}, {y, -0.1, 0.1}, {z, 3.8, 4.2}]

[Graphics:HTMLFiles/index_35.gif]

We can then estimate the slope of the function z = f(x, 0) at the point x = 0 to be about -1. Thus, we say that the partial derivative of f with respect to x at the point x = 0, y = 0 is approximately -1.

    Suppose that instead we want to find the partial derivative of f with respect to x at the point x = -0.5, y = -1. We first draw the graph of the function along the slice y = -1 as before.

YSlice[f, -1, {x, -3, 3}, {y, -3, 3}, {z, -10, 10}]

[Graphics:HTMLFiles/index_50.gif]

We then zoom in repeatedly near the point x = -0.5, y = -1, changing the range of z values for each graph as we do so.

YSlice[f, -1, {x, -1, 0}, {y, -1.5, -0.5}, {z, 0.5, 3.5}]

[Graphics:HTMLFiles/index_55.gif]

YSlice[f, -1, {x, -0.6, -0.4}, {y, -1.05, -0.95}, {z, 2.1, 2.4}]

[Graphics:HTMLFiles/index_57.gif]

We conclude that the partial derivative of f with respect to x at the point x = -0.5, y = -1 is approximately zero.

    There are a number of ways to write the partial derivative of f with respect to x symbolically. Two of the most common methods are ∂f/∂x and f_x. From our computations above, we see that
    
     FormBox[RowBox[{∂f/∂x (0, 0), =, RowBox[{f_x(0, 0), ≈, RowBox[{-1, Cell[]}]}]}], TraditionalForm]
     
and

    FormBox[RowBox[{∂f/∂x (-0.5, -1), =, RowBox[{f_x(-0.5, -1), ≈, RowBox[{0, Cell[]}]}]}], TraditionalForm].

    Now we might ask if we can do the same sort of process, but holding the x-variable fixed and letting the y-variable vary. To do just that, we have the following modification of the command YSlice, which we call XSlice.

XSlice[f_, xs_, {x, x0_, x1_}, {y, y0_, y1_}, {z, z0_, z1_}] := Module[{a, b, c, d}, a ... ;GraphicsArray[{c, d}], DisplayFunction$DisplayFunction, ImageSize600] ; ]

General :: spell1 : Possible spelling error: new symbol name \"XSlice\" is similar to existing symbol \"YSlice\".  More…

It is called in the same fashion as YSlice but now it takes as input an x-value, and returns the corresponding x-slice.

XSlice[f, 0, {x, -3, 3}, {y, -3, 3}, {z, -10, 10}]

[Graphics:HTMLFiles/index_75.gif]

    On the left is a plot of the function z = f(x, y) together with the plane x = 0. On the right is a plot of the function z = f(0, y). Since this is a function of one variable, we can ask what the derivative of this function is at some point, say y = 1. To find this, we can zoom in as we did before near the point (0, 1).

XSlice[f, 0, {x, -1, 1}, {y, 0, 2}, {z, 0, 10}]

[Graphics:HTMLFiles/index_82.gif]

XSlice[f, 0, {x, -0.1, 0.1}, {y, 0.9, 1.1}, {z, 3.5, 4.5}]

[Graphics:HTMLFiles/index_84.gif]

From the graph on the right, we conclude that the slope of the function z = f(0, y) at the point y = 1 is approximately -1. As a consequence, we say that the partial derivative of f with respect to y at the point x = 0, y = 1 is approximately -1. Symbolically, we write this as

    ∂f/∂y (0, 1) = f_y(0, 1) ≈ -1.

Experiment 7.1

    For each of the following functions below, use either XSlice or YSlice to graph the appropriate intersection curve. Then estimate the partial derivative in question graphically by zooming in repeatedly about a suitable point.

    1. f(x, y) = (25 - x^2 - y^2)^(1/2), find ∂f/∂y (2, -1).
    
    2. f(x, y) = 2x^2 - y^2, find ∂f/∂x (1, -1).
    
    3. f(x, y) = sin((x^2 + y^2)/6), find f_y(3, 3).
    
    4. f(x, y) = 3x - 2y + 5, find f_x(1, 2).
    
    5. f(x, y) = -x^2/2 - y^2 + 25/8, find f_y(1/2, 1).
    
    6.                                                                  2                     2 FormB ...  RowBox[{Cell[TextData[{Cell[BoxData[x ]], +, Cell[BoxData[y ]]}]], ^, (1/2)}]}], TraditionalForm], find f_x(3, 4).

Example 7.2, Algebraic Introduction to Partial Derivatives

    So far we have learned that given a point (x_0, y_0) and a function f(x, y) we could hold y = y_0 fixed, and examine the function xf(x, y_0). Because this is a function of one variable only, namely x, we can ask what the derivative of this function is at the point x = x_0. The result of this calculation we call the partial derivative of f with respect to x, and is written as ∂f/∂x (x_0, y_0) or f_x(x_0, y_0).
    We also saw that we could instead hold x = x_0 fixed, and examine the function yf(x_0, y), and then ask what the derivative of this function is when y = y_0. The result of this calculation is called the partial derivative of f with respect FormBox[Cell[TextData[Cell[BoxData[y]]]], TraditionalForm], and is written ∂f/∂y (x_0, y_0) or f_y(x_0, y_0).
    To make these ideas precise, let us consider the first case, where y = y_0 is held fixed. The definition of the derivative of the resulting function is
    ∂f/∂x (x_ (0,) y_0) = lim_ (h0) (f(x_0 + h, y_0) - f(x_0, y_0))/h
We notice that this has the same form as the standard definition of the derivative for a function of one variable, but that y = y_0 is held fixed. If we instead want the derivative of f with respect to y, we shall hold x = x_0 fixed and obtain
    ∂f/∂y (x_ (0,) y_0) = Underscript[lim, h0] (f(x_0, y_0 + h) - f(x_0, y_0))/h.
    To see these definitions in action, let us return to our original example.

f[x_, y_] := 4 - x + y - x^2 - y^2

In Example 7.1 we graphically calculated that f_x(0, 0) ≈ -1. Let us now verify that this is correct by using the definition. We first form the difference quotient as follows.

(f[h, 0] - f[0, 0])/h

(-h - h^2)/h

Then we simplify it

Simplify[(f[h, 0] - f[0, 0])/h]

-1 - h

and pass to the limit as h0

Limit[(f[h, 0] - f[0, 0])/h, h->0]

-1

We see that this agrees with our graphical calculations.
    Also in Example 7.1, we graphically calculated that f_y(0, 1) = -1. Let us also verify that this is correct. First calculate the difference quotient

(f[0, h + 1] - f[0, 1])/h

(1 + h - (1 + h)^2)/h

then simplify the result

Simplify[(f[0, h + 1] - f[0, 1])/h]

-1 - h

and pass to the limit

Limit[(f[0, h + 1] - f[0, 1])/h, h0]

-1

    Mathematica also has built-in commands to calculate partial derivatives directly. For example, if we want to calculate the derivative f_x, we can ask Mathematica

D[f[x, y], x]

-1 - 2 x

To evaluate this at a point, say (0, 0), we simply enter the following.

D[f[x, y], x] /. {x0, y0}

-1

Note that this agrees with our graphical computation and our limit computation. Similarly, we have

D[f[x, y], y]

1 - 2 y

D[f[x, y], y] /. {x0, y1}

-1

which also agrees with our previous calculations.

Experiment 7.2

    For each of the following functions,
        i) Find the partial derivatives f_x(x, y) and f_y(x, y). You may use any correct method to find the partial derivatives.
        ii) Find all of the points (x, y) where f_x(x, y) = f_y(x, y) = 0. Examine the graph of the function at these points, and describe the behavior of the function at each of these points.
        iii) Find the points where f_x(x, y) = 0 and f_y(x, y) = 3, and explain the behavior of the function at these points.
        iv) Find the points where f_x(x, y) = 3 and f_y(x, y) = 0, and explain the behavior of the function at these points.
        
    1. f(x, y) = x^2 + 1/2y^2.
    
    2. f(x, y) = x^2 - y^2.
    
    3.  f(x, y) = -5 (1 + x^2 + y^2)^(1/2).
    
    4.. f(x, y) = 3 - (x^2 + y^2).
    
    5.. f(x, y) = 3x - x^2y^2 + 2x^3y
    
    
    Remember that you can use the Solve command to solve equations.

Example 7.3, Tangent Planes

    One of the things that you may have noticed in Example 7.1 and Experiment 7.1 was that, as we zoomed in to a function more and more closely, the graph of the function looked more and more like a plane. This is analogous to the 2-dimensional case, where a differentiable function under repeated zooming looked more and more like a straight line. We remember from Calculus 1 that this line is in fact the tangent line to the graph of this function. For the same reason, we say that the plane that we approach under repeated zooming is the tangent plane to the graph of our function of two variables.
    We can use the partial derivatives of a function to find its tangent plane. Indeed, given a function f(x, y), then the tangent plane to this function at the point z_0 = f(x_0, y_0) is the plane
    
    z - z_0 =[∂f/∂x (x_ (0,) y_0)] (x - x_0) +[∂f/∂y (x_ (0,) y_0)] (y - y_0)
    
Let us look once again at the function

f[x_, y_] := 4 - x + y - x^2 - y^2

and suppose that we want to find the tangent plane to the graph of this function at the point (2, 1). We begin by calculating f_x(2, 1) and f_y(2, 1).

D[f[x, y], x]

-1 - 2 x

D[f[x, y], x] /. {x2, y1}

-5

D[f[x, y], y]

1 - 2 y

D[f[x, y], y] /. {x2, y1}

-1

We then calculate z_0 = f(x_0, y_0)

f[2, 1]

-2

FInally, combining these, we find that the tangent plane is z = -2 - 5 (x - 2) - (y - 1). We can verify that this is the case by plotting both the function and this plane. Remember that to do this, we must plot each graph separately and then use the Show command to combine them.

a = Plot3D[f[x, y], {x, -5, 5}, {y, -5, 5}, BoxRatios {1, 1, 1}] ;

[Graphics:HTMLFiles/index_189.gif]

b = Plot3D[-2 - 5 (x - 2) - (y - 1), {x, -5, 5}, {y, -5, 5}, BoxRatios {1, 1, 1}] ;

[Graphics:HTMLFiles/index_191.gif]

Show[b, a] ;

[Graphics:HTMLFiles/index_193.gif]

    Note that the x, y, and z ranges of the veiwing window for the plane and the surface are chosen to be identical. If we do not do this, our graph will only show a portion of the tangent plane or a portion of the graph of the function.
    Let us examine what happens to the function and its tangent plane as we zoom in towards the point at which we found the tangent plane; in this case towards the point (2, 1). We shall use the commands DisplayFunction->Identity so that we do not see the intermediate graphs, and then use the command DisplayFunction->$DisplayFunction to show the final graph.

a = Plot3D[f[x, y], {x, 1, 3}, {y, 0, 2}, BoxRatios {1, 1, 1}, DisplayFunction ... , 1, 1}, DisplayFunctionIdentity] ; Show[a, b, DisplayFunction$DisplayFunction] ;

[Graphics:HTMLFiles/index_199.gif]

Zooming in even further, we obtain the following.

a = Plot3D[f[x, y], {x, 1.8, 2.2}, {y, 0.8, 1.2}, BoxRatios {1, 1, 1}, DisplayFunction ... , 1, 1}, DisplayFunctionIdentity] ; Show[a, b, DisplayFunction$DisplayFunction] ;

[Graphics:HTMLFiles/index_201.gif]

We see that the tangent plane is looking more and more like the graph of the original function.

Experiment 7.3

    Find the equation of the tangent plane to each function at the indicated point, and give a graph showing both the function and the tangent plane. Zoom in on the graphs until the tangent plane and the function are nearly identical.

    1. f(x, y) =1/(1 + x^2 + y^2) at FormBox[Cell[(1,1)], TraditionalForm].
    
    2. f(x, y) = sin (x^2 + 2y^2)^(1/2) at (-1, 1) .
    
    3. f(x, y) = (x^2 + y^2) e^(-2x^2 - y^2) at (2, -1).
    
    4. f(x, y) = 3 - (x^2 + y^2) at (1/2, 1/3) .
    
    5. FormBox[RowBox[{f(x, y), =, RowBox[{Cell[TextData[Cell[BoxData[x]]]], ^x^2_y}]}], TraditionalForm] at (1, ln2).

Credits

These laboratories were created by Raouf Boules, Geoff Goodson, Ohoe Kim and Mike O'Leary for use in the Calculus courses of Towson University. Commercial use is prohibited without permission of the authors. Non-commercial use is permitted, provided this credit section is retained.


Created by Mathematica  (August 20, 2004)