Math Fundamentals · lesson 06/15
Derivation Rules & Examples
Differentiation is an algorithm, not a bag of tricks. A handful of rules covers every elementary function, and they compose: autograd and hand-written backprop code are both just these rules applied in order. Knowing them cold is what lets you read a gradient formula instead of trusting it.
The idea
| Rule | ||
|---|---|---|
| constant | ||
| power | ||
| sum | ||
| product | ||
| quotient | ||
| chain | ||
| exponential | ||
| logarithm | ||
| trig | ||
| trig |
Two facts make the table go further. First, and are inverses, and versus reflects that. Second, generic bases reduce to the natural ones: , so , and .
Worked example
Differentiate with the product rule, taking and :
At this gives . Direct substitution into the unfactored form gives the same: .
Now with the quotient rule:
At , . The derivative is negative everywhere it is defined: the function decreases on each side of its pole.
In code
import torch
x = torch.tensor(1.0, requires_grad=True)
y = x**2 * torch.exp(x)
y.backward()
print(x.grad) # tensor(8.1548) == 3eThe chain rule, covered next, is what makes the table composable. Its job is to connect the derivative you know locally to the variable you actually care about.
Check yourself
- Differentiate using the product rule.
- Rewrite as and derive the quotient rule from the product and chain rules.
- Differentiate and from the table plus the chain rule.
Key takeaways
- A small table of rules covers all elementary derivatives.
- Product and quotient rules are mechanical; the chain rule makes them composable.
- Reduce non-natural bases and logs to and before differentiating.