Derivatives, Optimisation, and Integrals
Derivatives
f'(a) = \lim_{h \to 0} \frac{f(a + h) - f(a)}{h}
Example: find the derivative of f(x) = x^2 + 3x from first principles
f'(x) = \lim_{h \to 0} \frac{f(x+h)-f(x)}{h}
f'(x) = \lim_{h \to 0} \frac{(x+h)^2 + 3(x+h) - (x^2+3x)}{h}
f'(x) = \lim_{h \to 0} \frac{x^2+2xh+h^2+3x+3h-x^2-3x}{h}
f'(x) = \lim_{h \to 0} \frac{2xh+h^2+3h}{h}
f'(x) = \lim_{h \to 0}(2x+h+3)
f'(x) = 2x+3
The first three are just different ways of writing the same thing — the derivative of a one-variable function:
This last one is a different situation, not just a fourth notation — a function of more than one variable:
[f(g(x))]' = f'(g(x)) \cdot g'(x)
When to use it: whenever a function is built by nesting one function inside another — a “function of a function”
In plain words: differentiate the outer function, then multiply by the derivative of the inner function
Why it matters: this is one of the most-used rules in anything that builds on this course — any time a quantity is created by feeding one relationship’s output into another, you need the chain rule to differentiate it
Before differentiating anything, practice just recognising the structure — which function is on the outside, which is nested inside:
The usual suspects for the outer function:
Spot one of these wrapped around something else, and the chain rule applies
Now spot the same structure quickly, without writing out the boxes:
(3x+5)^4 → outer: u^4 (a power) inner: u = 3x+5
\sqrt{2x-1} → outer: \sqrt{u} (a root) inner: u = 2x-1
\ln(5x+2) → outer: \ln(u) (a logarithm) inner: u = 5x+2
e^{4x-1} → outer: e^u (an exponential) inner: u = 4x-1
Take:
y = (2x+1)^3
Step 1 — identify the outer and inner functions (same technique as the previous slide): outer u^3, inner u = 2x+1, so y=u^3
Step 2 — differentiate the outer function (treat u as the variable): y = u^3 \Rightarrow y' = 3u^2
Step 3 — differentiate the inner function: u = 2x+1 \Rightarrow u' = 2
Step 4 — multiply the two, then substitute u back in: y' = 3u^2 \times 2 = 6u^2 = 6(2x+1)^2
Downs, A. (1957). An Economic Theory of Democracy. Harper & Row.
Model voter support S as a function of the policy characteristic x:
S(x) = -2x^2 + 20x + 3
Differentiate, then set to zero to find the peak of the support function:
S'(x) = -4x + 20
-4x + 20 = 0 \quad \Rightarrow \quad x = 5
Result: a policy characteristic of x=5 maximises voter support, at S(5) = 53.
A campaign’s total donations (in $ thousands), t days after launch, follow D(t) = -0.5t^2 + 20t + 100. Find the rate of change of donations at t=10, and interpret it.
D'(t) = -t + 20
D'(10) = 10
At day 10, donations are still rising — by about $10,000 per day — but the rate of increase is slowing down, and will reach zero at t=20.
Practice Time!
Optimisation
Local vs. global: the second derivative test only ever confirms a local max/min — the best value near that point. Whether it’s also the global max/min — the best value the function takes anywhere — depends on comparing every critical point (and the endpoints, if the domain is restricted). Today’s examples all happen to have exactly one critical point, so the local optimum and the global optimum coincide, but that’s not automatic in general.
Problem: Maximise f(x) = -2x^2 + 4x + 1
Step 1: f'(x) = \frac{d}{dx}(-2x^2+4x+1) = -4x+4
Step 2: Set f'(x)=0: -4x+4=0 \Rightarrow x=1
Step 3: Second derivative: f''(x) = -4, so f''(1) = -4 < 0 \Rightarrow x=1 is a maximum
Result: the maximum value is f(1) = -2(1)^2+4(1)+1 = 3
A campaign splitting a fixed ad budget between two channels whose combined reach is what matters
Problem: Maximise f(x,y) = xy subject to x+y=10
Step 1: Use the constraint to write y = 10-x
Step 2: Substitute into the objective: f(x) = x(10-x) = 10x - x^2
Step 3: Differentiate and set to zero: f'(x) = 10-2x = 0 \Rightarrow x=5
Step 4: Second derivative: f''(x)=-2<0, so x=5 is a maximum
Result: x=5, y=5, and f(5,5) = 5\times5 = 25
Problem: Minimise f(x) = x^2 - 4x + 7
Step 1: f'(x) = \frac{d}{dx}(x^2-4x+7) = 2x-4
Step 2: Set f'(x)=0: 2x-4=0 \Rightarrow x=2
Step 3: Second derivative: f''(x)=2, so f''(2) = 2 > 0 \Rightarrow x=2 is a minimum
Result: the minimum value is f(2) = (2)^2-4(2)+7 = 3
A coalition choosing a tax change x and a spending cut y that must jointly satisfy a fiscal rule, while keeping total voter backlash as low as possible
Problem: Minimise f(x,y) = x^2+y^2 subject to x+2y=8
Step 1: Use the constraint: x = 8-2y
Step 2: Substitute: f(y) = (8-2y)^2 + y^2
Step 3: Expand and differentiate: f(y) = 64-32y+5y^2, so f'(y) = -32+10y
Set f'(y)=0: -32+10y=0 \Rightarrow y=3.2
A coalition choosing a tax change x and a spending cut y that must jointly satisfy a fiscal rule, while keeping total voter backlash as low as possible
Problem: Minimise f(x,y) = x^2+y^2 subject to x+2y=8
Recap from the previous slide: f(y) = 64-32y+5y^2, f'(y) = -32+10y, critical point y=3.2
Step 4: Second derivative: f''(y) = 10 > 0 \Rightarrow minimum
Result: y=3.2, and x = 8-2(3.2) = 1.6
Minimum value: f(1.6, 3.2) = 1.6^2+3.2^2 = 2.56+10.24 = 12.8
A government’s approval rating, as a function of public spending x (in $ billions), is A(x) = -x^2 + 12x + 5. Find the spending level that maximises approval, and the resulting rating.
A'(x) = -2x+12
A'(x) = 0 \quad \Rightarrow \quad x=6
A''(x)=-2<0 \quad \Rightarrow \quad \textbf{maximum}
Result: spending $6bn maximises approval, at a rating of A(6)=41.
Practice Time!
Integrals
Groseclose, T., and J. M. Snyder Jr. (1996). Buying Supermajorities in Legislatures.
A legislator’s utility falls the further their vote deviates from the party’s preferred position p:
U(x) = -|x-p|
Legislators’ preferences x are spread out — some cluster near the party line, some sit further away. f(x) just describes how many legislators sit at each position x (we’ll properly define this as a “density” in Session 4). Integrating utility over [a,b] gives the party’s total influence:
\int_a^b U(x) f(x) \, dx
An integral is the area under a curve — the accumulation of a quantity:
\int_a^b f(x)\,dx \quad (\int:\text{integral sign};\ a,b:\text{limits};\ f(x):\text{integrand};\ dx:\text{variable})
Units: multiply the units on the two axes — (units of f(x)) \times (units of x) — not just “whatever’s on one axis.” A rate in voters per hour, integrated over hours, gives plain voters
Finding the value of C: on its own, C stays unknown — you need one extra piece of information, an initial condition such as a known value of the function, e.g. f(0)=5. Plug that point into the general antiderivative and solve for C
Fundamental Theorem: \displaystyle\int_a^b f(x)\,dx = F(b)-F(a)
e.g. \displaystyle\int_1^3 2x\,dx = \left[x^2\right]_1^3 = 3^2-1^2 = 8
Linearity: \displaystyle\int (af+bg)\,dx = a\!\int\! f\,dx + b\!\int\! g\,dx
e.g. \displaystyle\int (3x^2+5)\,dx = 3\!\int\! x^2\,dx + \int 5\,dx = 3\cdot\frac{x^3}{3} + 5x = x^3+5x+C
Additivity: \displaystyle\int_a^b f\,dx = \int_a^c f\,dx + \int_c^b f\,dx
e.g. \displaystyle\int_0^4 x\,dx = \int_0^2 x\,dx + \int_2^4 x\,dx = \left[\frac{x^2}{2}\right]_0^2 + \left[\frac{x^2}{2}\right]_2^4 = 2 + (8-2) = 2+6=8
Reversal of Limits: \displaystyle\int_a^b f\,dx = -\int_b^a f\,dx
e.g. \displaystyle\int_3^1 2x\,dx = -\int_1^3 2x\,dx = -8
Constant: \displaystyle\int c\,dx = cx + C (a rectangle)
e.g. \displaystyle\int_0^3 5\,dx = 5(3)-5(0) = 15 (a 3\times5 rectangle)
Zero Interval: \displaystyle\int_a^a f\,dx = 0
e.g. \displaystyle\int_3^3 2x\,dx = 0
Problem: Evaluate \displaystyle\int (3x^2+2x+1)\,dx
Apply linearity, then integrate each term:
\int (3x^2+2x+1)\,dx = \int 3x^2\,dx + \int 2x\,dx + \int 1\,dx
= 3\cdot\frac{x^3}{3} + 2\cdot\frac{x^2}{2} + x + C = x^3 + x^2 + x + C
Voter turnout on election day arrives at a rate of r(t) = 100 - 5t (thousand voters per hour), t hours after polls open. Find the total number of voters in the first 8 hours.
\int_0^8 (100-5t)\,dt = \left[100t - 2.5t^2\right]_0^8
= 800 - 160
= 640 \text{ thousand voters}
Practice Time!
Next session:
Maths Boot Camp