25 Partial change and the gradient vector
We have two ways by which we represent functions:
- As a computational algorithm for generating the output from an input(s), typically involving arithmetic and such.
- As a geometrical entity, specifically the graph of a function which can be a curve or, for functions of two inputs, a surface.
These two modes are sometimes intertwined, as when we use the name “line” to refer to a computational object:
Unfortunately for functions of two inputs, a surface is hard to present in the formats that are most easily at hand: a piece of paper, a printed page, a computer screen. That isbecause a curved surface is naturally a 3-dimensional object, while paper and screens provide two-dimensional images. Consequently, the graphics mode we prefer for presenting functions of two inputs is the contour plot, which is not a single geometrical object but a set of many objects: contours, labels, colored tiles.
We’ve been doing calculus on functions with one input because it is so easy to exploit both the computational mode and the graphical mode. And it might fairly be taken as a basic organizing theme of calculus that
a line segment approximates a curve in a small region around a point.
When figuring out the derivative function
Panel (A) in Figure 25.1 shows a smooth function
To restate what you already know, in the neighborhood of any input value
25.1 Calculus on two inputs
Although we use contour plots for good practical reasons, the graph of a function
A tangent plane is infinite in extent. Let’s use the word facet to refer to a little patch of the tangent plane centered at the point of contact. Each facet is flat. (it is part of a plane!) Figure 25.2 shows some facets tangent to a familiar curved surface. No two of the facets are oriented the same way.
Better than a picture of a summer melon, pick up a hardcover book and place it on a curved surface such as a basketball. The book cover is a flat surface: a facet. The orientation of the cover will match the orientation of the surface at the point of tangency. Change the orientation of the cover and you will find that the point of tangency will change correspondingly.
If melons and basketballs are not your style, you can play the same game on an interactive graph of a function with two inputs. The snapshot below is a link to an applet that shows the graph of a function as a blue surface. You can specify a point on the surface by setting the value of the (x, y) input using the sliders. Display the tangent plane (which will be green) at that point by check-marking the “Tangent plane” input. (Acknowledgments to Alfredo Sánchez Alberca who wrote the applet using the GeoGebra math visualization system.)
For the purposes of computation by eye, a contour graph of a surface can be easier to deal with. Figure 25.3 shows the contour graph of a smoothly varying function. Three points have been labeled A, B, and C.
Zooming in on each of the marked points presents a simpler picture for each of them, although one that is different for each point. Each zoomed-in plot contains almost parallel, almost evenly spaced contours. If the surface had been exactly planar over the entire zoomed-in domain, the contours would be exactly parallel and exactly evenly spaced. We can approach such exact parallelness by zooming in more closely around the labeled point.
Just as the function
In the bottom row of Figure 25.4, the facets tangent to the original surface at A, B, and C are displayed. Comparing the top and bottom rows of Figure 25.4) you can see that each facet has the same orientation as the surface; the contours face in the same way.
Remember that the point of constructing such facets is to generalize the idea of a derivative from a function of one input
One clue comes from the formula for a function whose graph is a plane oriented in a particular direction:
An instructive experience is to pick up a rigid, flat object, for instance a smartphone or hardcover book. Hold the object level with pinched fingers at the mid-point of each of the short ends, as shown in Figure 25.5 (left).
You can tip the object in one direction by raising or lowering one hand. (middle picture) And you can tip the object in the other coordinate direction by rotating the object around the line joining the points grasped by the left and right hands. (right picture) By combining these two motions, you can orient the surface of the object in a wide range of directions.1
The purpose of this lesson is to show that two-numbers are sufficient to dictate the orientation of a plane. In terms of Figure 25.5 these are 1) the amount that one hand is raised relative to the other and 2) the angle of rotation around the hand-to-hand axis.
Similarly, in the formula for a plane, the orientation is set by two numbers,
How do we find the right
Look carefully at the formulas for the slices. In
The parameters
These derivatives of slice functions are called partial derivatives. The word “partial” refers to examining just one input at a time. In the above formulas, the
You don’t need to create the slices explicitly to calculate the partial derivatives. Simply differentiate
Similarly,
Get in the habit of noticing the subscript on the differentiation symbol
25.2 All other things being equal …
Recall that the derivative of a function with one input, say,
Now that we are in the domain of multiple inputs, writing
With this notation, we write the first-order polynomial approximation to a function of a single input
Each of these statements is about changing one input while holding the other input(s) constant. Or, as the more familiar expression goes, “The effect of changing one input all other things being equal or all other things held constant.2
Everything we’ve said about differentiation rules applies not just to functions of one input,
25.3 Gradient vector
For functions of two inputs, there are two partial derivatives. For functions of three inputs, there are three partial derivatives. We can, of course, collect the partial derivatives into Cartesian coordinate form. This collection is called the gradient vector.
Just as our notation for differences (
Note that
The graphics convention for drawing a gradient vector for a particular input, that is,
A gradient field (see Figure 25.7) is the value of the gradient vector at each point in the function’s domain. Graphically, to prevent over-crowding, the vectors are drawn at discrete points. The lengths of the drawn vectors are set proportional to the numerical length of
25.4 Total derivative (optional)
The name “partial derivative” suggests the existence of some kind of derivative that is not just a part, but the whole thing. The total derivative is such a whole and gratifyingly made up of its parts, that is, the partial derivatives.
Suppose you are modeling the temperature of some volume of the atmosphere, given as
The partial derivatives have an easy interpretation:
The total derivative gives an overall picture of the changes in a parcel of air, which you can thnk of as a tiny balloon-like structure but without the balloon membrane. The temperature inside the “balloon” may change with time (e.g. condensation or evaporation of water), but as the ballon drifts along with the motion of the air (that is, the wind), the evolving location can change the temperature as well. Think of a balloon caught in an updraft: the temperature goes down as the balloon ascends.
For an imaginary observer located in the balloon, the temperature is changing with time. Part of this change is the instrinsic change measured by
Likewise, the total derivative of temperature with respect to the observer riding in the balloon will be add together the parts due to changes in time (holding position constant), x-coordinate (holding time and the other space coordinates constant), and the like. Signifying the total differentiation with a capital
Note that
Formulations like this, which put the parts of change together into a whole, are often seen in the mathematics of fluid flow as applied in meteorology and oceanology.
25.5 Differentials
A little bit of this, a little bit of that. — Stevie Wonder, “The Game of Love”
We have framed calculus in terms of functions: transformations that take one (or more!) quantities as input and return a quantity as output. This was not the original formulation. In this section, we will use the original style to demonstrate how you can sometimes skip the step of constructing a function before differentiating to answer a question of the sort: “If this quantity changes by a little bit, how much will another, related quantity change?”
As an example, consider the textbook-style problem of a water skier being pulled along the water by a rope pulled in from the top of a tower of height
In the function style of approach, we can write the position function
Differentiate both sides with respect to
Now to reformulate the problem without defining a function.
Newton referred to “flowing quantities” or “fluents” and to what today is universally called derivatives as “fluxions.” Newton did not have a notion of inputs and output.3
At about the same time as Newton’s inventions, very similar ideas were being given very different names by mathematicians on the European continent. There, an infinitely small change in a quantity was called a “differential” and the differential of
The first calculus textbook was subtitled, Of the Calculus of Differentials, in other words, how to calculate differentials. (See Figure 25.8.) Section I of this 1696 text is entitled, “Where we give the rules of this calculation,” those rules being recognizably the same as presented in Chapter Chapter 23 of this book.
Definition I of Section I states,
“We call quantities variable* that grow or decrease continuously; and to the contrary constant quantities are those that remain the same while the others change. … The infinitely small amount by which a continuous quantity increases or decreases is called the differential.*”
The differential is not a derivative. The differential is an infinitely small change in a quantity and a derivative is a rate of change. The differential of a quantity
The point of Section I of de l’Hôpital’s textbook is to present the rules by which the differentials of complex quantities can be calculated. You will recognize the product rule in de l’Hôpital’s notation:
The Pythagorean theorem relates the various quantities this way:
The differential of each side of the equation refers to “a little bit” of increase in the quantity on that side of the equation:
Think of this as a recipe for calculating
We will return to “a little bit of this” when we explore how to add up little bits to get the whole in Chapter Chapter 38.
25.6 Drill
Part 1 What is
Part 2 What is
Part 3 What is
Part 4 What is
Part 5 What is
Part 6 What is
Part 7 What is
Part 8 What is
Part 9 What is
Part 10 What is
0
Part 11 What is
0
Part 12 What is
0
Part 13 What is
Part 14 What is
Part 15 What is
Part 16 What is
Part 17 What is
Part 18 What is
Part 19 What is
Part 20 What is
Part 21 What is
Part 22 What is
Part 23 What is
Part 24 What is
0
Part 25 What is
- 0
Part 26 What is
0 1
Part 27 What is
- 0
Part 28 What is
- $ g(y) _y h(x,y) + h(x,y) _y g(y)$
- 0
Part 29 What is
Part 30 What is
Part 31 What is the “with-respect-to” input in
Part 32 What is the “with-respect-to” input in
Part 33 What is the “with-respect-to” input in
Part 34
At which of these inputs is the function steepest in the x-direction?
Part 35
At which of these inputs is the function practically flat?
Part 36
You are standing on the input point
NE SE SW NW
Part 37
You are standing on the input point
NE SE SW NW
Part 38
You have been hiking all day and have reached map coordinate (x=2, y=2). You are completely exhausted. Time for a break. You want to walk along the hill, without any change of elevation. Which compass direction should you head in to get started?
NE or SW SE but not NW NW or SE NW but not SE
Part 39 Symbolically compute
Part 40 Symbolically compute
Part 41 Symbolically compute
25.7 Exercises
Exercise 25.01
It is relatively easy to assess partial derivatives when you know the gradient. After all, the gradient is the vector of
Part A What is the rule for determining
- If the vector has a component pointing right,
is positive. - If the vector has a component pointing left,
is positive - If the vector has a vertical component pointing up,
is positive. - If the vector has a component pointing downward, the partial derivative
is positive.
Part B What is the rule for determining
- If the vector has a component pointing right,
is positive. - If the vector has a component pointing left,
is positive. - If the vector has a vertical component pointing up,
is positive. - If the vector has a component pointing downward, the partial derivative
is positive.
Exercise 25.02
Open a sandbox and use the following commands to make a contour plot of the function
<- rfun( ~ x + y, seed = 802, n = 15)
g <- 0
x0 <- 0
y0 <- 5
size contour_plot(g(x, y) ~ x + y,
bounds(x = x0 + size*c(-1, 1),
y = y0 + size*c(-1, 1)))
By making size
smaller, you can zoom in around the reference point. Zoom in gradually (say, size =
1.0, 0.5, 0.1, 0.05, 0.01) until you reach a point where the surface plot is (practically) a pretty simple inclined plane.
From the contour plot, zoomed in so that the graph shows an inclined plane, figure out the sign of
Part A Which answer best describes the signs of the partial derivatives of
is pos, is pos is pos, is neg is neg, is neg is neg, is pos. is 0, is pos
Exercise 25.04
Consider this close up of a function around a reference point at the center of the graph.
By eye, estimate these derivatives of the function at the reference point
Part A What is the numerical value of
-1 -0.50 -0.25 0 0.25 0.50 1
Part B What is the numerical value of
-1 -0.50 -0.25 0 0.25 0.50 1
The next questions ask about second-order partial derivatives. As you know, the second derivative is about how the first derivative changes with x or y. Insofar as the function is a simple inclined plane, where the contours would be straight, parallel, and evenly spaced, the second derivatives would all be zero. But you can see that it is not such a plane: the contours curve a bit.
In determining the second derivatives by eye from the graph, you are encouraged to compare first derivatives at the opposing edges of the graph, as opposed to at very nearby points.
Part C What is the sign of
negative positive
Part D What is the sign of
negative positive
Part E What is the sign of
negative positive
Part F What is the sign of
negative positive
Exercise 25.06
At numerous occasions in your professional life, you will be in one or both of these positions:
- You are a decision-maker being presented with the results of analysis conducted by a team of unknown reliability, and you need to figure out whether what they are telling you is credible.
- You are a member of the analysis team needing to demonstrate to the decision-maker that your work should be believed.
As an example, consider one of the functions presented in a comedy book, Geek Logic: 50 Foolproof Equations for Everyday Life (2006), by Garth Sundem. The particular function we will consider here is Dr()
, intended to help answer the question, “Should you go to the doctor?”
= How many days in the past month have you been incapacitated? = Does the issue seem to be getting better or worse. (-10 to 10 with -10 being “circling the drain” and 10 being “dramatic improvement”) = How much pain or discomfort are you currently experiencing? (1-10 with 10 being “currently holding detached toe in Ziploc bag”) = How embarrassing is this issue? (1-10 with 10 being “slipped on ice and fell on 1972 Mercedes-Benz hood ornament, which is now part of my body”) = How noticeable is the issue? (1-10 with 10 being “fell asleep on waffle iron”) = How serious does the issue seem? (1-10 with 10 being “may well have nail embedded in frontal lobe [of brain]”)
Although the function is offered tongue-in-cheek, let’s examine it to see if it even roughly matches common sense. The tool we will use relates to low-order polynomial approximation around a reference point and examining appropriate partial derivatives. To save time, we stipulate a reference point for you, noted in the description of quantities above.
The code creates an R implementation of the function that is set up so that the default values of the inputs are those at the given reference point. You can use this in a sandbox to try different changes in each of the input quantities.
<- makeFun(
Dr ^2)/2 + e*(n-e)) /
((s100 - 3*(d + (p^3/70) - c)) ~
(+p+e+c+n+s, s=3, n=5, e=4, p=3, d=3, c=-2)
dDr()
According to the instructions in the book, if Dr()
Essay 1: The value of Dr()
at the reference point is 0.10, indicating that you shouldn’t go to the doctor. But we don’t yet know whether 0.10 is very close to the decision threshold of 1 or very far away. Describe a reasonable way to figure this out. Report your description and the results here.
Essay 2: There are six inputs to the function. Go through the list of all six and (without thinking too hard about it) write down for all of them your intuitive sense of whether an increase of one point in that input should raise or lower the output of Dr() at the reference point. Also write down whether you think the input should be a large or small determinant of whether to go to the doctor. (You don’t need to refer to the Dr() function itself, just to your own intuitive sense of what should be the effect of each of the inputs.)
The operator D()
can calculate partial derivatives. You can calculate the value of a partial derivative very easily at the reference point, using an expression like this, which gives the value of the partial of Dr() with respect to input
D(Dr(s = s) ~ s)(s=3)
We are now going to use these partial derivatives to compare your intuition about going to the doctor to what the function has to say. Of course, we don’t know yet whether the function is reasonable, so don’t be disappointed if your intuition conflicts with the function.
Essay 3: Calculate the numerical value of each of the partial derivatives at the reference point. List them here and say, for each one, whether it accords with your intuition.
Exercise 25.07
Each of the figures below shows a contour plot and a gradient field. For some of the figures, the contour plot and the gradient field show the same function, for others they do not. Your task is to identify whether the contour plot and the gradient field are of the same or different functions.
Part A For Figure A, do the contour plot and the gradient field show the same function?
Yes No
Part B For Figure B, do the contour plot and the gradient field show the same function?
Yes No
Part C For Figure C, do the contour plot and the gradient field show the same function?
Yes No
Part D For Figure D, do the contour plot and the gradient field show the same function?
Yes No
Part E For Figure E, do the contour plot and the gradient field show the same function?
Yes No
Part F For Figure F, do the contour plot and the gradient field show the same function?
Yes No
Exercise 25.08
Here is a contour plot of a function
Part A What’s wrong with gradient field 1?
- arrows point down the hill instead of up it
- magnitude of arrows are wrong, but direction is right
- arrows don’t point in the right direction
- nothing is wrong
Part B What’s wrong with gradient field 2?
- arrows point down the hill instead of up it
- magnitude of arrows are wrong, but direction is right
- arrows don’t point in the right direction
- nothing is wrong
Part C What’s wrong with gradient field 3?
- arrows point down the hill instead of up it
- magnitude of arrows are wrong, but direction is right
- arrows don’t point in the right direction
- nothing is wrong
Part D What’s wrong with gradient field 4?
- arrows point down the hill instead of up it
- magnitude of arrows are wrong, but direction is right
- arrows don’t point in the right direction
- nothing is wrong
Exercise 25.10
Here are contour maps and gradient fields of several functions with input
Part A Which contour plot matches gradient field 1?
A B C D E F
Part B Which contour plot matches gradient field 2?
A B C D E F
Part C Which contour plot matches gradient field 3?
A B C D E F
Part D Which contour plot matches gradient field 4?
A B C D E F
Part E Which contour plot matches gradient field 5?
A B C D E F
Part F Which contour plot matches gradient field 6?
A B C D E F
Exercise 25.12
Using the gradient field depicted below, figure out the sign of the partial derivatives at the labeled points. We will use “neg” to refer to negative partial derivatives, “pos” to refer to positive partial derivatives, and “zero” to refer to partials that are so small that you cannot visually distinguish them from zero.
Part A Which is
neg zero pos
Part B Which is
neg zero pos
Part C Which is
neg zero pos
Part D Which is
neg zero pos
Part E Which is
neg zero pos
Part F Which is
neg zero pos
Part G At which letter are both the partial with respect to
A B C D E F none of them
Exercise 25.13
The graph depicts the effect of a drug on heart rate. Each of the lines shows heart rate as a function of dose for a given age. The drug’s effect depends both on the dose of the drug and on the age of the person taking the drug.
Using the information shown in the graph, estimate numerically each of the following partial derivatives, giving proper units for each. (Heart rate is measured in “bpm” (beats per minute) and dose in “mg”.)
- The derivative
- at dose
, age - at dose
, age - at dose
, age
- at dose
at dose , age . at dose , age . at dose , age . at dose , age .
The graphic above is three slices through the function HR(dose, age). One slice is for age 20, one slice for age 30, and the last for age 40. This is a standard graphical format in the technical literature, sometimes called an interaction plot since it emphasizes the interaction between age and dose.
Of course, we can plot the same function HR(dose, age) as a contour plot.
- Which contour plot matches the interaction graph?
- On the correct contour plot, draw the paths that correspond to the graph of HR versus dose for each of ages 20, 30, and 40 years.
Exercise 25.14
For almost everyone, a house is too expensive to buy with cash, so people need to borrow money. The usual form of the loan is called a “mortgage”. Mortgages extend over many years and involve paying a fixed amount each month. That amount is calculated so that, by paying it each month for the duration of the mortgage, the last payment will completely repay the amount borrowed plus the accumulated interest.
The monthly mortgage payment in dollars,
A studio apartment is selling for $220,000. You will need to borrow $184,000 to make the purchase.
Part A Suppose
- The monthly cost of borrowing $184,000 for 10 years at 4% interest per year.
- The monthly cost of borrowing $184,000 for 4 years at 10% interest per year.
- The annual cost of the mortgage at 4% interest for 10 years.
- The annual cost of the mortgage at 10% interest for 4 years
The next two questions involve what happens to the monthly mortgage payments if you change either the amount or duration of the mortgage. (Hint: Common sense works wonders!)
Part B What would you expect about the quantity
It is positive It is zero It is negative
Part C What would you expect about the quantity
It is positive It is zero It is negative
Part D Suppose
- If the interest rate
went up from 4 to 5, the monthly payment would increase by $145.65. - If the interest rate
went up from 4 to 4.001, the monthly payment would increase by $145.65. - If the interest rate
went up from 4 to 4.001, the monthly payment would increase by $0.001 imes $145.65.
Exercise 25.16
In economic theory, the quantity of the demand for any good is a decreasing function of the price of that good and an increasing function of the price of a competing good.
The classical example is that apple juice competes with orange juice. The demand for orange juice is in units of thousands of liters of orange juice. The price is in units of dollars per liter.
Here’s a graph with the input quantities unlabeled. The contour labels indicate the demand for orange juice.
The concept of partial derivatives makes it much easier to think about the situation. There are two partial derivative functions relevant to the function in the graph. Well denote the inputs apple
and orange
, but remember that these are the prices of those commodities in dollars per liter.
– how the demand changes when apple-juice price goes up, holding orange-juice price constant. (Another notation that is more verbose but perhaps easier to read ) – how the demand changes when orange-juice price goes up, holding apple-juice price constant. (Another notation: )
Notice that the notation names both the output and the single input which is to be changed–the other inputs will be held constant.
The first paragraph of this problem gives the economic theory which amounts to saying that one of the partial derivatives is positive and the other negative.
Part A What is the proper translation of the notation
- The partial derivative of orange-juice demand with repect to apple-juice price
- The partial derivative of apple-juice price with respect to demand for orange juice
- The partial derivative of apple-juice demand with respect to price of apple juice
- The partial derivative of orange-juice price with respect to apple-juice price.
Part B According to the economic theory described above, one of the partial derivatives will be positive and the other negative. Which will be positive.
Part C What does the vertical axis measure?
- Price of orange juice
- Quantity of apple juice
- Quantity of orange juice
- Price of apple juice
Part D Consider the magnitude (absolute value) of the partial derivative of demand with respect to orange-juice price. Is this magnitude greater toward the top of the graph or the bottom?
top bottom neither
Exercise 25.18
The contour plot of function
Part A What’s wrong with the red vector?
- nothing
- too long
- too short
- points downhill
- points uphill
- wrong direction entirely
Part B What’s wrong with the green vector?
- nothing
- too long
- too short
- points downhill
- points uphill
- wrong direction entirely
Part C What’s wrong with the blue vector?
- nothing
- too long
- too short
- points downhill
- points uphill
- wrong direction entirely
Part D What’s wrong with the orange vector?
- nothing
- too long
- too short
- points downhill
- points uphill
- wrong direction entirely
Part E What’s wrong with the gray vector?
nothing too long too short points downhill points uphill
Exercise 25.20
Let’s return to the water skier in Section 25.5. When we left her, the rope was being pulled in at 10 feet per second and her corresponding speed on the water was 10.05 feet per second. The relationship between the rope speed and the skier’s speed was
What happens to
This is bad news for the skier who holds on too long! As
You, an engineer brought in to solve this dangerous possibility, have proposed to have the winch slow down as the rope is reeled in. How should the speed of the rope be set so that the skier’s water speed remains safely constant?
Part A What formula for
- There is no such formula.
In describing the orientation of aircraft and ships, three parameters are used: pitch, roll, and yaw. For a geometrical plane (as opposed to an aircraft or ship, which have distinct front and back ends), yaw isn’t applicable.↩︎
The Latin phrase for this is ceteris paribus, often used in economics.↩︎
The meaning of “output” as “to produce” dates from more than 100 years after Newton’s death.↩︎
A “warning” is given in the textbook that the symbol
will always be used to mark the differential of a variable quantity and that will never be used to indicate a parameter.↩︎