Common Derivatives

Most differentiation in practice is pattern matching: memorize a short table of derivatives plus a few combination rules, and you can differentiate nearly any function that appears in statistics or disease modeling by inspection.

Reference table#

Function f(x)f(x)Derivative f′(x)f'(x)
cc (constant)00
xnx^nn xn−1n\,x^{n-1}
exe^xexe^x
axa^xaxln⁡aa^x \ln a
ln⁡x\ln x1x\dfrac{1}{x}
log⁡ax\log_a x1xln⁡a\dfrac{1}{x \ln a}
sin⁡x\sin xcos⁡x\cos x
cos⁡x\cos x−sin⁡x-\sin x
tan⁡x\tan xsec⁡2x=1cos⁡2x\sec^2 x = \dfrac{1}{\cos^2 x}

Combination rules#

Constant multiple:

ddx[c f(x)]=c f′(x)\frac{d}{dx}\big[c\,f(x)\big] = c\,f'(x)

Sum (and difference):

ddx[f(x)±g(x)]=f′(x)±g′(x)\frac{d}{dx}\big[f(x) \pm g(x)\big] = f'(x) \pm g'(x)

The power rule ddxxn=nxn−1\frac{d}{dx}x^n = n x^{n-1} holds for any real nn, so it also covers roots (x1/2x^{1/2}) and reciprocals (x−1x^{-1}).

Worked example: differentiating a polynomial#

Let f(x)=3x4−5x2+7x−2f(x) = 3x^4 - 5x^2 + 7x - 2. Differentiate term by term using the power, constant-multiple, and sum rules:

f′(x)=3⋅4x3−5⋅2x1+7⋅1−0=12x3−10x+7.\begin{aligned} f'(x) &= 3 \cdot 4x^{3} - 5 \cdot 2x^{1} + 7 \cdot 1 - 0 \\ &= 12x^3 - 10x + 7 . \end{aligned}

At x=1x = 1: f′(1)=12−10+7=9f'(1) = 12 - 10 + 7 = 9.

Computing it#

R#

R
D(expression(x^n), "x")        # x^n * (n * (1/x))  == n*x^(n-1)
D(expression(exp(x)), "x")     # exp(x)
D(expression(log(x)), "x")     # 1/x
D(expression(sin(x)), "x")     # cos(x)
D(expression(3*x^4 - 5*x^2 + 7*x - 2), "x")
#   3 * (4 * x^3) - 5 * (2 * x) + 7   == 12x^3 - 10x + 7

Python#

Python
import sympy as sp
x, a, n = sp.symbols("x a n")

sp.diff(x**n, x)        # n*x**n/x  == n*x**(n-1)
sp.diff(a**x, x)        # a**x*log(a)
sp.diff(sp.log(x), x)   # 1/x
sp.diff(sp.tan(x), x)   # tan(x)**2 + 1  == sec^2 x
sp.diff(3*x**4 - 5*x**2 + 7*x - 2, x)   # 12*x**3 - 10*x + 7

Julia#

Julia
using Symbolics
@variables x a

Symbolics.derivative(exp(x), x)   # exp(x)
Symbolics.derivative(log(x), x)   # 1 / x
Symbolics.derivative(sin(x), x)   # cos(x)
Symbolics.derivative(3x^4 - 5x^2 + 7x - 2, x)   # 7 + 12(x^3) - 10x

Why it matters for statistics#

These building blocks recur throughout biology: the exponential’s derivative governs early outbreak growth and the first-order elimination of a drug from the bloodstream, while the log’s derivative 1/x1/x appears every time we differentiate a log-likelihood to fit a model. These few rules cover the derivatives you meet constantly: polynomial regression terms, the exe^x in exponential growth and logistic models, and the ln⁡x\ln x at the heart of every log-likelihood. Knowing them cold lets you derive score equations and standard errors without reaching for software.