Linear Algebra
11.510 min read

Symbolic Computation of Partial Derivatives

Computing partial derivatives symbolically is straightforward: treat all variables except the one you are differentiating with respect to as constants, then apply ordinary differentiation rules (power, product, quotient, chain rules).

For example, if f(x,y,z)=x2sin(y)+exzf(x, y, z) = x^2 \sin(y) + e^{xz}, then: fx=2xsin(y)+zexz,fy=x2cos(y),fz=xexz\frac{\partial f}{\partial x} = 2x\sin(y) + ze^{xz}, \quad \frac{\partial f}{\partial y} = x^2\cos(y), \quad \frac{\partial f}{\partial z} = xe^{xz}

The chain rule applies within partial differentiation: if f(x,y)=g(h(x,y))f(x,y) = g(h(x,y)) for some inner function hh, then f/x=g(h(x,y))h/x\partial f/\partial x = g'(h(x,y)) \cdot \partial h/\partial x. This is used constantly in neural networks (backpropagation is repeated application of this rule).

Formal View

Example 11.1 — Computing Partial Derivatives
Let f(x,y)=x3y2ln(x2+y2)f(x, y) = x^3 y^2 - \ln(x^2 + y^2). fx=3x2y22xx2+y2\frac{\partial f}{\partial x} = 3x^2 y^2 - \frac{2x}{x^2+y^2} fy=2x3y2yx2+y2\frac{\partial f}{\partial y} = 2x^3 y - \frac{2y}{x^2+y^2}
Remark 11.2 — Chain Rule for Partial Derivatives
If z=f(u,v)z = f(u, v) where u=u(x,y)u = u(x,y) and v=v(x,y)v = v(x,y), then
zx=fuux+fvvx\frac{\partial z}{\partial x} = \frac{\partial f}{\partial u}\frac{\partial u}{\partial x} + \frac{\partial f}{\partial v}\frac{\partial v}{\partial x}
This is the multivariable chain rule, which we study in detail in Chapter 14.

Why This Matters

Symbolic partial differentiation is one of the most frequently performed operations in applied mathematics and machine learning.

  • Computing gradients of loss functions with respect to model parameters (deep learning)
  • Finding critical points of energy functions in physics and engineering
  • Deriving normal equations and optimality conditions in statistics

Quiz

Question 1

Let f(x,y)=sin(x2y)f(x,y) = \sin(x^2 y). Then fx\frac{\partial f}{\partial x} equals:

Question 2

Let f(x,y,z)=xyz2f(x,y,z) = xyz^2. What is 2fzx\frac{\partial^2 f}{\partial z \partial x}?

Common Mistakes

  • Differentiating variables that should be treated as constants — always identify which variable you are differentiating with respect to.
  • Forgetting the chain rule when the function of interest is a composition.
  • Errors in mixed partials: remember to differentiate with respect to the outermost symbol last.