Maths Boot Camp: Session 3

Derivatives, Optimisation, and Integrals

Session 3 Topics

  • Derivatives (definition, notation, rules)
  • Optimisation: Maximisation and Minimisation
  • Integrals

Block 1

Derivatives

Derivatives

  • In plain terms: nudge x a tiny step away from a — how much does f(x) change?
  • Definition: the rate of change of f at a point a — exactly that question, made precise:

f'(a) = \lim_{h \to 0} \frac{f(a + h) - f(a)}{h}

  • Numerator: change in output (f at the nudged point, minus f at a)    Denominator: size of the nudge, h
  • Why divide by h? the raw change in output depends on how big the nudge was — dividing by h converts it into a rate: change in output per unit of input, i.e. a slope, so it no longer depends on how big we picked h to be
  • Result: the slope of the tangent line at a

The Derivative — Secant Line and the Nudge

Applying the Definition

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

Derivatives — Notation

The first three are just different ways of writing the same thing — the derivative of a one-variable function:

  • Prime (Lagrange): f'(x) — emphasises the outcome
  • Leibniz: \frac{dy}{dx} or \frac{df(x)}{dx} — emphasises the operation
  • Euler: D_x f(x) or Df(x)

This last one is a different situation, not just a fourth notation — a function of more than one variable:

  • Partial derivative (Leibniz, multiple variables): \frac{\partial z}{\partial x} or \frac{\partial f(x,y)}{\partial x} — derivative with respect to x, holding every other variable fixed

Differentiation Rules

  1. Constant: \frac{d}{dx}[c] = 0
  2. Constant Multiple: \frac{d}{dx}[c \cdot f(x)] = c \cdot f'(x)
  3. Sum: \frac{d}{dx}[f(x) + g(x)] = f'(x) + g'(x)
  4. Difference: \frac{d}{dx}[f(x) - g(x)] = f'(x) - g'(x)
  1. Power: \frac{d}{dx}[x^n] = nx^{n-1}
  2. Product: \frac{d}{dx}[f(x)\cdot g(x)] = f'(x)g(x) + f(x)g'(x)
  3. Quotient: \frac{d}{dx}\left[\frac{f(x)}{g(x)}\right] = \frac{f'(x)g(x) - f(x)g'(x)}{[g(x)]^2}
  4. Chain: \frac{d}{dx}[f(g(x))] = f'(g(x)) \cdot g'(x)

The Chain Rule

[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

The Chain Rule — Building a Composition

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:

  • Power: u^n (squaring, cubing, any exponent)
  • Root: \sqrt{u}, i.e. u^{1/2}
  • Logarithm: \ln(u)
  • Exponential: e^u

Spot one of these wrapped around something else, and the chain rule applies

The Chain Rule — Spot the Outer and Inner Function

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

The Chain Rule — Worked Example

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

Applied Example — Downs’ Spatial Model of Voting (1957)

Downs, A. (1957). An Economic Theory of Democracy. Harper & Row.

  • Parties choose a position on some policy characteristic x — e.g. how large a proposed tax should be, or how strict a regulation should be
  • Different positions attract different levels of voter support
  • The question: what value of x wins the most support?

Applied Example — Downs’ Spatial Model of Voting (1957)

Model voter support S as a function of the policy characteristic x:

S(x) = -2x^2 + 20x + 3

Applied Example — Downs’ Spatial Model of Voting (1957)

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.

Quick Check — Derivatives

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.

Towards the End of Block 1

Practice Time!

Block 2

Optimisation

Optimisation

  • Finding the optimal value of f(x): the x that either maximises or minimises it, possibly subject to constraints

Maximisation

  • Finding x that makes f(x) as large as possible, possibly subject to constraints
  • Application: a government choosing how much to spend on public programmes — more spending raises welfare, but every extra pound is harder to raise than the last, so there’s a spending level that does the most overall good

The Role of the Second Derivative

  • First derivative f'(x)=0: finds critical points (max, min, or inflection)
  • Second derivative f''(x): tells you which one, by measuring which way the curve bends
  • f''(x) < 0: bends downward, like a dome \Rightarrow flat point sits at the top \Rightarrow maximum
  • f''(x) > 0: bends upward, like a bowl \Rightarrow flat point sits at the bottom \Rightarrow minimum

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.

Maximisation Problem Without Constraint

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

Maximisation Problem With Constraint

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

Minimisation

  • Finding x that makes f(x) as small as possible, possibly subject to constraints
  • Application: a central bank setting interest rates — cutting rates too little leaves unemployment high, cutting them too much overheats the economy with inflation, so there’s a rate that does the least harm

Minimisation Problem Without Constraint

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

Minimisation Problem With Constraint

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

Minimisation Problem With Constraint (cont.)

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

Quick Check — Optimisation

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.

Towards the End of Block 2

Practice Time!

Block 3

Integrals

Applied Example — Groseclose and Snyder (1996)

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|

Applied Example — Groseclose and Snyder (1996)

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

Integrals

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

Basic Integration Rules

  1. Constant: \displaystyle\int c\,dx = c\cdot x + C
  2. Power (for n \neq -1): \displaystyle\int x^n\,dx = \frac{x^{n+1}}{n+1} + C
  3. Sum / Difference: \displaystyle\int [f(x)\pm g(x)]\,dx = \int f(x)\,dx \pm \int g(x)\,dx
  4. Constant Multiple: \displaystyle\int c\cdot f(x)\,dx = c\cdot\int f(x)\,dx

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

Properties of Integrals — Fundamental Theorem

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

Properties of Integrals — Linearity

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

Properties of Integrals — Additivity

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

Properties of Integrals — Reversal of Limits

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

Properties of Integrals — Constant

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)

Properties of Integrals — Zero Interval

Zero Interval: \displaystyle\int_a^a f\,dx = 0

e.g. \displaystyle\int_3^3 2x\,dx = 0

Integration Problem — Integrating a Polynomial

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

Quick Check — Integrals

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}

Towards the End of Block 3

Practice Time!

End of Session

Next session:

  1. Counting Principles and Techniques
  2. Probability, Law of Total Probability, Bayes’ Theorem
  3. Level of Measurement, Random Variables, Distributions