10. Partial derivatives
§10.1 showed that a two-variable limit has infinitely many directions to worry about — which makes "the derivative of f(x,y)" a genuinely harder question than it was for one variable. This lesson sidesteps the full difficulty for now, by asking a simpler question first: how does f change in just one coordinate direction at a time, holding everything else fixed? The answer turns out to need no new differentiation rules at all — every technique from Module 2 applies immediately.
Definition
The partial derivative of f(x,y) with respect to x treats y as a constant and differentiates as if f were a function of x alone:
\frac{\partial f}{\partial x}=f_x(x,y)=\lim_{h\to0}\frac{f(x+h,y)-f(x,y)}h
— exactly §2.0's difference-quotient definition, with y frozen in place throughout the limit. The partial derivative with respect to y is defined symmetrically, freezing x instead.
In practice, no limit is ever computed directly. Since y is treated as a literal constant while differentiating with respect to x, every rule from Module 2 — power, product, quotient, chain — applies exactly as before, just with an extra "constant" sitting in the expression that happens to be labeled y instead of a number.
For f(x,y)=x^2y^3+\sin(xy):
f_x=2xy^3+y\cos(xy)\qquad\text{(treat $y$ as constant; use the chain rule on $\sin(xy)$, inner derivative $y$)}
f_y=3x^2y^2+x\cos(xy)\qquad\text{(treat $x$ as constant; inner derivative of $xy$ with respect to $y$ is $x$)}
Geometric meaning
Recall §10.0: z=f(x,y) graphs as a surface. Fixing y=y_0 slices that surface with a vertical plane, producing an ordinary curve z=f(x,y_0) — and f_x(x_0,y_0) is exactly that curve's slope at x=x_0, §2.0's tangent-line slope, applied to the sliced curve. Fixing x=x_0 instead and varying y gives the perpendicular slice, with slope f_y(x_0,y_0).
A single point on a surface has two different tangent-line slopes — one along each coordinate direction — where a curve y=f(x) only ever had one. §10.5's directional derivative generalizes this further, to a slope in any direction, not just the two coordinate ones; partial derivatives are the special case of that idea restricted to directions along the x-axis or y-axis.
Higher-order partial derivatives
Differentiating a partial derivative again produces a second-order partial derivative. There are four for a two-variable function:
f_{xx}=\frac{\partial}{\partial x}\left(\frac{\partial f}{\partial x}\right),\quad f_{yy}=\frac{\partial}{\partial y}\left(\frac{\partial f}{\partial y}\right),\quad f_{xy}=\frac{\partial}{\partial y}\left(\frac{\partial f}{\partial x}\right),\quad f_{yx}=\frac{\partial}{\partial x}\left(\frac{\partial f}{\partial y}\right)
f_{xx} and f_{yy} are the direct three-dimensional analogue of §3.5's second derivative — measuring concavity along each coordinate slice individually. f_{xy} and f_{yx} are mixed partials: differentiate with respect to one variable, then the other.
Clairaut's theorem: mixed partials agree
If f_{xy} and f_{yx} are both continuous near a point, then f_{xy}=f_{yx} there.
The order of differentiation doesn't matter, for any function well-behaved enough to matter in practice. This is a genuinely useful fact computationally — whichever order is more convenient to differentiate in can always be chosen — and it will resurface directly in §10.6's second-derivative test for classifying extrema, where f_{xy} appears in the discriminant and its value being unambiguous (regardless of computation order) is quietly assumed throughout.
Doing it in Python
Computing all four second-order partials for f(x,y)=x^2y^3+\sin(xy), and confirming Clairaut's theorem directly:
import sympy as sp
x, y = sp.symbols('x y')
f = x**2 * y**3 + sp.sin(x*y)
f_x = sp.diff(f, x)
f_y = sp.diff(f, y)
f_xy = sp.diff(f_x, y)
f_yx = sp.diff(f_y, x)
print(f"f_x = {f_x}")
print(f"f_y = {f_y}")
print(f"f_xy = {f_xy}")
print(f"f_yx = {f_yx}")
print(f"\nmixed partials agree: {sp.simplify(f_xy - f_yx) == 0}")
Interpreting partial derivatives as slice slopes — comparing f_x and f_y at a specific point to the slopes of the two perpendicular slices through the paraboloid f(x,y)=x^2+y^2:
import sympy as sp
x, y = sp.symbols('x y')
f = x**2 + y**2
f_x = sp.diff(f, x)
f_y = sp.diff(f, y)
point = {x: 1, y: 2}
print(f"f_x(1,2) = {f_x.subs(point)} -- slope of the x-slice at y=2")
print(f"f_y(1,2) = {f_y.subs(point)} -- slope of the y-slice at x=1")
# confirm directly: slice at y=2 is z = x^2 + 4, an ordinary function of x
slice_x = (x**2 + 4)
print(f"\nordinary derivative of the x-slice, x^2+4: {sp.diff(slice_x, x).subs(x, 1)}")
Using higher-order partials directly, without any new rules:
import sympy as sp
x, y = sp.symbols('x y')
f = sp.exp(x*y) * sp.cos(x)
f_xx = sp.diff(f, x, 2) # second partial derivative w.r.t. x, y held constant throughout
f_yy = sp.diff(f, y, 2)
print(f"f_xx = {sp.simplify(f_xx)}")
print(f"f_yy = {sp.simplify(f_yy)}")
Worked example
Find f_x, f_y, f_{xy}, and f_{yx} for f(x,y)=x^2y^3+\sin(xy), and confirm Clairaut's theorem.
Treating y as constant (power rule on x^2y^3, chain rule on \sin(xy) with inner derivative \frac\partial{\partial x}(xy)=y):
f_x=2xy^3+y\cos(xy)
Treating x as constant:
f_y=3x^2y^2+x\cos(xy)
Differentiate f_x with respect to y (product rule on y\cos(xy), plus the power-rule term):
f_{xy}=\frac\partial{\partial y}\big[2xy^3+y\cos(xy)\big]=6xy^2+\cos(xy)+y\cdot\big(-x\sin(xy)\big)=6xy^2+\cos(xy)-xy\sin(xy)
Differentiate f_y with respect to x (product rule on x\cos(xy), plus the power-rule term):
f_{yx}=\frac\partial{\partial x}\big[3x^2y^2+x\cos(xy)\big]=6xy^2+\cos(xy)+x\cdot\big(-y\sin(xy)\big)=6xy^2+\cos(xy)-xy\sin(xy)
\boxed{f_{xy}=f_{yx}=6xy^2+\cos(xy)-xy\sin(xy)}
Sanity check. Both computations start from different functions (f_x versus f_y) and involve different intermediate steps (product rule applied to a different factor each time), yet land on the identical expression — exactly Clairaut's theorem's guarantee, and a genuine computational check that neither differentiation was performed incorrectly along the way, since an arithmetic slip in either path would very likely have produced mismatched results. ✓
Your turn
1. Find f_x and f_y for f(x,y)=x^3y^2-4xy+y.
2. Find f_{xx}, f_{yy}, and f_{xy} for f(x,y)=e^{xy}.
3. True or false: for every function f(x,y), no matter how it's constructed, f_{xy}=f_{yx} always.
Solutions
1. Treating y constant: f_x=3x^2y^2-4y. Treating x constant: f_y=2x^3y-4x+1.
\boxed{f_x=3x^2y^2-4y,\qquad f_y=2x^3y-4x+1}
2. f_x=ye^{xy} (chain rule, inner derivative y). f_{xx}=y^2e^{xy} (differentiate again, treating y as constant). f_y=xe^{xy}, so f_{yy}=x^2e^{xy}. f_{xy}=\frac\partial{\partial y}\big[ye^{xy}\big]=e^{xy}+y\cdot xe^{xy}=e^{xy}(1+xy) (product rule).
\boxed{f_{xx}=y^2e^{xy},\quad f_{yy}=x^2e^{xy},\quad f_{xy}=e^{xy}(1+xy)}
3. False. Clairaut's theorem requires f_{xy} and f_{yx} to be continuous near the point in question — a genuine hypothesis, not an automatic guarantee for every conceivable function. There exist specially-constructed (typically piecewise) functions where f_{xy} and f_{yx} both exist at a point but disagree there, precisely because continuity fails. For every function encountered in ordinary practice — polynomials, exponentials, trig functions, and their combinations, as in every example this lesson used — the hypothesis holds automatically, but it is a hypothesis, not a theorem-free guarantee.
Check yourself in code
For f(x,y)=x^2y^3+\sin(xy), compute f_{xy} and f_{yx} with SymPy and confirm they match.
Print exactly this:
f_xy = 6*x*y**2 - x*y*sin(x*y) + cos(x*y)
f_yx = 6*x*y**2 - x*y*sin(x*y) + cos(x*y)
match: True
import sympy as sp
x, y = sp.symbols('x y')
f = x**2 * y**3 + sp.sin(x*y)
f_x = sp.diff(f, x)
f_y = sp.diff(f, y)
f_xy = sp.diff(f_x, y)
f_yx = sp.diff(f_y, x)
print("f_xy = ...")
print("f_yx = ...")
print("match: ...")
import sympy as sp
x, y = sp.symbols('x y')
f = x**2 * y**3 + sp.sin(x*y)
f_x = sp.diff(f, x)
f_y = sp.diff(f, y)
f_xy = sp.diff(f_x, y)
f_yx = sp.diff(f_y, x)
print(f"f_xy = {f_xy}")
print(f"f_yx = {f_yx}")
print(f"match: {sp.simplify(f_xy - f_yx) == 0}")
A partial derivative freezes every variable except one and differentiates normally — no new rules needed, only Module 2's toolkit applied with an extra symbol treated as a constant — and it measures the slope of the curve carved by slicing the surface z=f(x,y) parallel to one coordinate axis. Second-order mixed partials, f_{xy} and f_{yx}, always agree by Clairaut's theorem whenever both are continuous, a fact quietly relied on throughout the rest of this module.
Next: bundling all of a function's partial derivatives together into a single tangent plane — the two-variable generalization of §3.1's tangent line.