Product and Quotient Rules
When two changing quantities are multiplied or divided, the result changes for two reasons at once. The product and quotient rules account for both. They are the tools for derivatives like , , or when both move.
The product rule
"Derivative of the first times the second, plus the first times the derivative of the second." A picture explains it: is the area of a rectangle with sides and . If grows by and by , the area grows by . Divide by and let it go to 0: the tiny corner vanishes, and the two strips remain.
Check by expanding first: , derivative . Same answer.
The quotient rule
A memory aid: "low d-high minus high d-low, over low squared". The order matters because of the minus sign.
The result is always negative, so this function decreases on each side of its asymptote at .
Checking with SymPy
import sympy as sp
x = sp.symbols('x')
f, g = x**2 + 3, sp.sin(x)
by_rule = sp.diff(f, x) * g + f * sp.diff(g, x)
print("product rule:", by_rule)
print("sp.diff :", sp.diff(f * g, x))
print("equal? :", sp.simplify(by_rule - sp.diff(f * g, x)) == 0)
q = (x + 1) / (x - 1)
print("quotient :", sp.simplify(sp.diff(q, x)))product rule: 2*x*sin(x) + (x**2 + 3)*cos(x)
sp.diff : 2*x*sin(x) + (x**2 + 3)*cos(x)
equal? : True
quotient : -2/(x - 1)**2
sp.simplify(a - b) == 0 is a reliable way to test whether two formulas are the same function.
Numeric evidence
The product rule against central differences for at a few points ():
import math
def F(x):
return x**2 * math.exp(x)
def F_prime(x): # product rule
return 2 * x * math.exp(x) + x**2 * math.exp(x)
h = 1e-5
for x0 in [-2.0, 0.0, 0.5, 1.0, 3.0]:
numeric = (F(x0 + h) - F(x0 - h)) / (2 * h)
print(f"x = {x0:4} numeric {numeric:12.6f} rule {F_prime(x0):12.6f}")x = -2.0 numeric -0.000000 rule 0.000000
x = 0.0 numeric 0.000000 rule 0.000000
x = 0.5 numeric 2.060902 rule 2.060902
x = 1.0 numeric 8.154845 rule 8.154845
x = 3.0 numeric 301.283054 rule 301.283054
At the slope is exactly 0: there has a local maximum, a fact we will use in Maxima, Minima and Curve Shape.
Quotient rule examples
| Function | Derivative |
|---|---|
Tip: If the numerator or denominator is a constant, skip the quotient rule. differentiates instantly with the power rule to .
In software
- Revenue and pricing: revenue . Its derivative says raising the price earns more per unit () but loses some sales (, negative). Setting finds the best price.
- Normalisation in ML: softmax, layer norm and cosine similarity all divide one expression by another. Their gradients in a framework's backward pass are quotient-rule derivatives, written out once and reused.
- Perspective projection: screen coordinates are and . How fast a point moves on screen when the camera moves is a quotient-rule derivative, which is why nearby objects seem to move faster (projection).
Exercises
Exercise 1: Product rule
Differentiate with the product rule.
Answer
Solution
Check: expanded , so .
Exercise 2: Quotient rule
Differentiate .
Answer
Solution
Exercise 3: Horizontal tangents
Where does have a horizontal tangent?
Answer
At and .
Solution
Exercise 4: Best price
Weekly sales of an app subscription at price are . Use to find the price that maximises revenue, and confirm with SymPy.
Answer
, revenue 6250.
Solution
import sympy as sp
p = sp.symbols('p')
R = p * (1000 - 40 * p)
best = sp.solve(sp.diff(R, p), p)[0]
print(best, R.subs(p, best))25/2 6250
Test yourself
What is the product rule?
What is ?
In the quotient rule , what happens if you swap the order of the terms in the numerator?
- The answer gets the wrong sign
- Nothing changes
- The answer doubles
- It becomes the product rule