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^nnxn1n\,x^{n-1}
exe^xexe^x
axa^xaxlnaa^x \ln a
lnx\ln x1x\dfrac{1}{x}
logax\log_a x1xlna\dfrac{1}{x \ln a}
sinx\sin xcosx\cos x
cosx\cos xsinx-\sin x
tanx\tan xsec2x=1cos2x\sec^2 x = \dfrac{1}{\cos^2 x}

Combination rules

Constant multiple:

ddx[cf(x)]=cf(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=nxn1\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 (x1x^{-1}).

Worked example: differentiating a polynomial

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

f(x)=34x352x1+710=12x310x+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)=1210+7=9f'(1) = 12 - 10 + 7 = 9.

Computing it

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

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

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 lnx\ln x at the heart of every log-likelihood. Knowing them cold lets you derive score equations and standard errors without reaching for software.