Linear Algebra
10.167 min read

Symbolic Differentiation

Using differentiation rules, we can compute derivatives symbolically — by manipulating formulas rather than computing limits each time. The monomial rule is key: ddx(axk)=akxk1\frac{d}{dx}(a x^k) = a k x^{k-1} for any constants a,ka, k.

Combined with the sum rule, this lets us differentiate any polynomial instantly: ddx(3x42x2+5)=12x34x\frac{d}{dx}(3x^4 - 2x^2 + 5) = 12x^3 - 4x. With the chain rule and product rule, we can differentiate any composition of elementary functions.

Symbolic differentiation underlies automatic differentiation in modern ML frameworks: the framework stores the computation graph and applies differentiation rules backward (backpropagation) to compute gradients efficiently.

Formal View

Example 10.2 — Symbolic Differentiation of a Polynomial
Differentiate f(x)=5x33x2+7x2f(x) = 5x^3 - 3x^2 + 7x - 2: f(x)=53x232x+710=15x26x+7f'(x) = 5 \cdot 3x^2 - 3 \cdot 2x + 7 \cdot 1 - 0 = 15x^2 - 6x + 7. Each term is differentiated using (axk)=akxk1(ax^k)' = akx^{k-1}, and results are summed by the sum rule.

Why This Matters

Symbolic differentiation is the basis of automatic differentiation systems that power modern machine learning.

  • PyTorch/TensorFlow compute gradients symbolically via the computation graph.
  • Solving optimization problems: set the symbolic derivative to zero and solve for critical points.
  • Checking numerical derivatives: symbolic results serve as ground truth for finite-difference approximations.

Quiz

Question 1

What is f(x)f'(x) for f(x)=4x36x+1f(x) = 4x^3 - 6x + 1?

Question 2

The derivative of a constant is zero.

Common Mistakes

  • Forgetting the coefficient in the power rule: (5x3)=15x2(5x^3)' = 15x^2, not 5x25x^2 or x2x^2.
  • Differentiating the constant term as non-zero: (c)=0(c)' = 0 always.