Rules for derivatives

Computing limits every time would be slow. A few rules give the derivative of almost any formula.

Common derivatives

FunctionDerivative
a constant c0
xⁿn·xⁿ⁻¹
sin xcos x
cos x−sin x
eˣeˣ
ln x1/x

Combining functions

  • Sum: (f + g)′ = f′ + g′. Derivatives work term by term, so 3x² + 5x has derivative 6x + 5.
  • Product: (f·g)′ = f′·g + f·g′.
  • Chain (a function inside a function): the derivative of f(g(x)) is f′(g(x)) · g′(x). The derivative of sin(x²) is cos(x²) · 2x.

Check it with a computer

The central difference (f(x + h) − f(x − h)) ÷ 2h is a much better estimate than the one-sided quotient. The example compares it with each rule at x = 1.

from math import sin, cos

def numeric(f, x, h=1e-5):
    return (f(x + h) - f(x - h)) / (2 * h)

x = 1.0
print("x^3:", round(numeric(lambda t: t ** 3, x), 4), " rule 3x^2:", 3 * x ** 2)
print("x sin x:", round(numeric(lambda t: t * sin(t), x), 4), " product rule:", round(sin(x) + x * cos(x), 4))
print("sin(x^2):", round(numeric(lambda t: sin(t * t), x), 4), " chain rule:", round(cos(x * x) * 2 * x, 4))
Open in compiler

The numbers agree to four decimals, which is good evidence the rules were applied correctly. Automatic differentiation, used to train every neural network, applies the chain rule like this to millions of operations.

Common mistakes

  • Forgetting the inner derivative in the chain rule: the derivative of sin(3x) is 3cos(3x), not cos(3x).
  • Writing (f·g)′ = f′·g′. Try f = g = x: (x²)′ = 2x, not 1.

Quick check

1. Derivative of 5x³?
2. By the chain rule, the derivative of sin(3x) is…
3. The product rule says (f·g)′ = …

Practice problems for this lesson

My notes

Write down what you want to remember from this lesson. Notes are saved on this device as you type, and appear on your dashboard.