Quotient Rule

The quotient rule differentiates a ratio of two functions. Ratios are everywhere in epidemiology — prevalence proportions, hazard ratios, and the logistic curve are all quotients whose rates of change we often need. Frequency-dependent transmission βSI/N\beta S I / N and prevalence I/NI/N are ratios of quantities that all change over time, so differentiating such a per-capita rate calls for the quotient rule.

The rule#

ddx[f(x)g(x)]=f(x)g(x)f(x)g(x)[g(x)]2\frac{d}{dx}\left[\frac{f(x)}{g(x)}\right] = \frac{f'(x)\,g(x) - f(x)\,g'(x)}{\big[g(x)\big]^2}

Order matters in the numerator: it is “derivative of top times bottom, minus top times derivative of bottom,” all over the bottom squared.

Intuition#

Write the quotient as a product fg1f \cdot g^{-1} and apply the product and chain rules:

ddx[fg1]=fg1+f(g2g)=fgfgg2=fgfgg2.\frac{d}{dx}\big[f g^{-1}\big] = f' g^{-1} + f\,(-g^{-2} g') = \frac{f'}{g} - \frac{f g'}{g^2} = \frac{f' g - f g'}{g^2}.

So the quotient rule is not a new idea — it is the product rule in disguise.

Worked example: the logistic-type ratio x1+x\dfrac{x}{1+x}#

Let f(x)=xf(x) = x and g(x)=1+xg(x) = 1 + x, so f(x)=1f'(x) = 1 and g(x)=1g'(x) = 1:

ddx[x1+x]=(1)(1+x)x(1)(1+x)2=1(1+x)2.\frac{d}{dx}\left[\frac{x}{1+x}\right] = \frac{(1)(1+x) - x(1)}{(1+x)^2} = \frac{1}{(1+x)^2}.

The derivative is always positive, so x1+x\frac{x}{1+x} increases toward its saturating limit of 11 — the same “diminishing returns” shape as a saturating incidence or dose-response curve. At x=1x = 1 the slope is 14\tfrac{1}{4}.

Computing it#

R#

R
# Symbolic
D(expression(x / (1 + x)), "x")
#   1/(1 + x) - x/(1 + x)^2   == 1/(1+x)^2

# Numeric check at x = 1
library(numDeriv)
grad(function(x) x / (1 + x), 1)   # 0.25

Python#

Python
import sympy as sp
x = sp.symbols("x")
sp.simplify(sp.diff(x / (1 + x), x))   # 1/(x + 1)**2

# Numeric check at x = 1
h = 1e-6
f = lambda x: x / (1 + x)
(f(1 + h) - f(1 - h)) / (2 * h)        # ~0.25

Julia#

Julia
using Symbolics
@variables x
simplify(Symbolics.derivative(x / (1 + x), x))   # (1 + x)^-2

using ForwardDiff
ForwardDiff.derivative(x -> x / (1 + x), 1.0)     # 0.25

Why it matters for statistics#

Proportions, rates, and probabilities are ratios, and models like logistic regression are built from them. Differentiating these quotients is how we obtain the score functions and delta-method standard errors for estimated proportions and odds.