Chapter 14. Partial derivatives

§14.1 [TEXT] The point of differentiation is linear approximation

In 18.01, when 𝑓:ℝ→ℝ, you defined a derivative 𝑓′(𝑝) at each input 𝑝∈ℝ, which you thought of as the slope of the tangent line at 𝑝. Think 𝑓(5.01)≈𝑓(5)+𝑓′(5)⋅0.01. This slope roughly tells you, if you move a slight distance away from the input 𝑝, this is how fast you expect 𝑓 to change. To drill the point home again, in 18.01, we had

𝑓(𝑝+𝜀)≈𝑓(𝑝)+𝑓′(𝑝)⋅𝜀.

See figure below.

Figure 33: In 18.01, the slope 𝑓′(𝑝) tells you how quickly 𝑓 changes near 𝑝.

The 18.01 derivative had type “scalar”. But for a two-variable function, that’s not enough. For concreteness, let’s take

𝑓(𝑥,𝑦)=𝑥2+𝑦2

as our example function (for which we have drawn level curves before), and consider some point 𝑃=(3,4), so that 𝑓(3,4)=25.

Then, what would a point “close” to (3,4) mean? The point (3.01,4) is close, but so is (3,4.01). For that matter, so is (3.006,4.008) — that’s also a point at distance 0.01 away! So having a single number isn’t enough to describe the rate of change anymore.

For a two-variable function, we would really want two numbers, in the sense that we want to fill in the blanks in the equation

𝑓(3+𝜀𝑥,4+𝜀𝑦)≈25+(slope in𝑥-direction)⋅𝜀𝑥+(slope in𝑦-direction)⋅𝜀𝑦.
Idea
For an 𝑛-variable functions, we have a rate of change in each of the 𝑛 directions. Therefore, we need 𝑛 numbers and not just one.

The first blank corresponds to what happens if you imagine 𝑦 is held in place at 4, and we’re just changing the 𝑥-value to 3.01. The second blank is similar. So we need a way to calculate these; the answer to our wish is what’s called a partial derivative.

§14.2 [TEXT] Computing partial derivatives is actually just 18.01

The good news about partial derivatives is that they’re actually really easy to calculate. You pretty much just need to do what you were taught in 18.01 with one variable changing while pretending the others are constants.

Here’s the definition:

Definition

Suppose 𝑓(𝑥,𝑦) is a two-variable function. Then the partial derivative with respect to 𝑥, which we denote either 𝑓𝑥 or 𝜕𝑓𝜕𝑥, is the result if we differentiate 𝑓 while treating 𝑥 as a variable and 𝑦 as a constant. The partial derivative 𝑓𝑦=𝜕𝑓𝜕𝑦 is defined the same way.

Similarly, if 𝑓(𝑥,𝑦,𝑧) is a three-variable function, we write 𝑓𝑥=𝜕𝑓𝜕𝑥 for the derivative when 𝑦 and 𝑧 are fixed.

Type signature

Each partial derivative has the same type signature as 𝑓. That is:

  • Given 𝑓:ℝ𝑛→ℝ which accepts points in ℝ𝑛 and outputs scalars.
  • Then the partial derivative 𝜕𝑓𝜕𝑥=𝑓𝑥 also accepts points in ℝ𝑛 and outputs scalars.

But that’s a lot of words. I think this is actually better explained by example. In fact you could probably just read the examples and ignore the definition above.

Example: partial derivatives of 𝑓(𝑥,𝑦)=𝑥3𝑦2+cos(𝑦)

Let 𝑓(𝑥,𝑦)=𝑥3𝑦2+cos(𝑦).

Let’s compute 𝑓𝑥. Again, pretend 𝑦 is a constant, so look at the function

𝑥↦𝑦2⋅𝑥3+cos(𝑦).

If we differentiate with respect to 𝑥, then 𝑥3 becomes 3𝑥2, and cos(𝑦) goes to 0 (it doesn’t have any 𝑥 stuff in it). So

𝑓𝑥=𝑦2⋅3𝑥2.

Similarly, let’s compute 𝑓𝑦. This time we pretend 𝑥 is a constant, and look at

𝑦↦𝑥3⋅𝑦2+cos(𝑦).

This time 𝑦2 becomes 2𝑦, and cos(𝑦) has derivative −sin(𝑦). So

𝑓𝑦=𝑥3⋅2𝑦−sin(𝑦).
Example: partial derivatives of 𝑓(𝑥,𝑦,𝑧)=𝑒𝑥𝑦𝑧

Let 𝑓(𝑥,𝑦,𝑧)=𝑒𝑥𝑦𝑧 for a three-variable example. To compute 𝑓𝑥, think of the function

𝑥↦𝑒𝑦𝑧⋅𝑥

where we pretend 𝑦 and 𝑧 are constants. Then the derivative is with respect to 𝑥 is just 𝑦𝑧𝑒𝑦𝑧⋅𝑥 (just like how the derivative of 𝑒3𝑥 is 3𝑒3𝑥). In other words,

𝑓𝑥(𝑥,𝑦,𝑧)=𝑦𝑧⋅𝑒𝑥𝑦𝑧.

For analogous reasons:

𝑓𝑦(𝑥,𝑦,𝑧)=𝑥𝑧⋅𝑒𝑥𝑦𝑧𝑓𝑧(𝑥,𝑦,𝑧)=𝑥𝑦⋅𝑒𝑥𝑦𝑧.
Example: partial derivatives of 𝑓(𝑥,𝑦)=𝑥2+𝑦2 and linear approximation

Let’s go back to

𝑓(𝑥,𝑦)=𝑥2+𝑦2

which we used in our earlier example as motivation, at the point 𝑃=(3,4).

Let’s fill in the numbers for the example 𝑓(𝑥,𝑦)=𝑥2+𝑦2 we chose. By now, you should be able to compute that

𝑓𝑥(𝑥,𝑦)=2𝑥𝑓𝑦(𝑥,𝑦)=2𝑦

Now, let’s zoom in on just the point 𝑃=(3,4). We know that

𝑓(𝑃)=32+42=25𝑓𝑥(𝑃)=2⋅3=6𝑓𝑦(𝑃)=2⋅4=8.

So our approximation equation can be written as

(3+𝜀𝑥)2+(4+𝜀𝑦)2≈25+6𝜀𝑥+8𝜀𝑦.

(10)

If you manually expand both sides, you can see this looks true. The two sides differ only by 𝜀𝑥2 and 𝜀𝑦2, and the intuition is that if 𝜀𝑥 and 𝜀𝑦 were small numbers, then their squares will be negligibly small.

We’ll return to Equation 10 later when we introduce the gradient.

§14.3 [RECIPE] Computing partial derivatives

You probably can already figure out the recipe from the sections above, but let’s write it here just for completeness.

Recipe for calculating partial derivatives

To compute the partial derivative of a function 𝑓(𝑥,𝑦) or 𝑓(𝑥,𝑦,𝑧) or 𝑓(𝑥1,…,𝑥𝑛) with respect to one of its input variables,

  1. Pretend all the other variables are constants, and focus on just the variable you’re taking the partial derivative to.
  2. Calculate the derivative of 𝑓 with respect to just that variable like in 18.01.
  3. Output the derivative you got.

This is easy, and only requires 18.01 material.

We just saw three examples where we computed the partials for 𝑓(𝑥,𝑦)=𝑥3𝑦2+cos(𝑦), 𝑓(𝑥,𝑦,𝑧)=𝑒𝑥𝑦𝑧, and 𝑓(𝑥,𝑦)=𝑥2+𝑦2. Here are a bunch more examples that you can try to follow along:

Sample Question
Calculate the partial derivatives of 𝑓(𝑥,𝑦,𝑧)=𝑥+𝑦+𝑧.

Solution. The partial derivative with respect to 𝑥 is obtained by differentiating

𝑥↦𝑥+𝑦+𝑧.

Since we pretend 𝑦 and 𝑧 are constants, we just differentiate 𝑥 to get 1. The same thing happens with 𝑦 and 𝑧. Hence

𝑓𝑥(𝑥,𝑦,𝑧)=1𝑓𝑦(𝑥,𝑦,𝑧)=1𝑓𝑧(𝑥,𝑦,𝑧)=1.

□

Sample Question
Calculate the partial derivatives of 𝑓(𝑥,𝑦,𝑧)=𝑥𝑦+𝑦𝑧+𝑧𝑥.

Solution. We differentiate with respect to 𝑥 first, where we view as the function

𝑥↦(𝑦+𝑧)𝑥+𝑦𝑧

pretending that 𝑦 and 𝑧 are constants. This gives derivative 𝑓𝑥(𝑥,𝑦,𝑧)=𝑦+𝑧. Similarly, 𝑓𝑦(𝑥,𝑦,𝑧)=𝑥+𝑧 and 𝑓𝑧(𝑥,𝑦,𝑧)=𝑥+𝑦. So

𝑓𝑥(𝑥,𝑦,𝑧)=𝑦+𝑧𝑓𝑦(𝑥,𝑦,𝑧)=𝑧+𝑥𝑓𝑧(𝑥,𝑦,𝑧)=𝑥+𝑦.

□

Sample Question
Calculate the partial derivatives of 𝑓(𝑥,𝑦)=𝑥𝑦, where we assume 𝑥,𝑦>0.

Solution. If we view 𝑦 as a constant and 𝑥 as a variable, then

𝑥↦𝑥𝑦

is differentiated by the “power rule” to get 𝑦𝑥𝑦−1. However, if we view 𝑥 as constant and 𝑦 as a variable, then

𝑦↦𝑥𝑦=𝑒log𝑥⋅𝑦

ends up with derivative log𝑥⋅𝑒log𝑥⋅𝑦=log𝑥⋅𝑥𝑦. (Remember, in this book log denotes the natural log.) Hence

𝑓𝑥(𝑥,𝑦)=𝑦𝑥𝑦−1𝑓𝑦(𝑥,𝑦)=log𝑥⋅𝑥𝑦.

□

§14.4 [EXER] Exercises

Exercise 14.1. Compute all the partial derivatives of the following functions, defined for 𝑥,𝑦,𝑧>0: