Lecture Notes: Calculus for Social Scientists

POSC 8410, Week 6 — board derivations and You Try answers

Author

Will Horne

Published

October 26, 2026

(possible) Board derivations

1. The derivative

Slides: What Is a Limit?, From Secant to Tangent.

Key point: \(h\) in the denominator cancels before you take the limit. For \(f(x) = x^{2}\):

\[\frac{f(x+h) - f(x)}{h} = \frac{(x+h)^{2} - x^{2}}{h} = \frac{2xh + h^{2}}{h} = 2x + h\]

Now let \(h \to 0\): \(f'(x) = 2x\). At \(x = 1.5\) that is 3, the number on the secant figure, and the table on the limits slide is this expression with \(x = 1.5\), namely \(3 + h\).

At \(h = 0\) the quotient is \(0/0\), so we never evaluate there. Instead, we ask for the quotient as h goes to 0.

2. Why the mean minimizes squared error

Slide: Why Is the Mean the Mean?

Minimize \(S(c) = \sum_{i=1}^{n}(x_i - c)^{2}\) over \(c\). Differentiate with the chain rule, one term at a time:

\[S'(c) = \sum_{i=1}^{n} 2(x_i - c)(-1) = -2\sum_{i=1}^{n}(x_i - c)\]

Set it to zero and the \(-2\) divides out:

\[\sum_{i=1}^{n} x_i - nc = 0 \quad \Longrightarrow \quad c = \frac{1}{n}\sum_{i=1}^{n} x_i = \bar{x}\]

Finish with the second-order condition, which is often skipped: \(S''(c) = 2n > 0\), so this is a minimum rather than a maximum.

Swap the squared penalty for an absolute one and you get the median.

income <- c(45, 50, 52, 47, 60, 55, 120, 28, 430, 73)
c(mean = mean(income), median = median(income))
  mean median 
  96.0   53.5 
c(sum(abs(income - 52)), sum(abs(income - 53.5)), sum(abs(income - 55)))
[1] 516 516 516

3. From the mean to OLS, if there is time (there wasn’t)

Slide: Preview: This Is What OLS Does.

Identical set up, with an extra parameter. Minimize \(S(a, b) = \sum (y_i - a - b x_i)^{2}\), now setting two partial derivatives to zero:

\[\frac{\partial S}{\partial a} = -2\sum (y_i - a - b x_i) = 0, \qquad \frac{\partial S}{\partial b} = -2\sum x_i (y_i - a - b x_i) = 0\]

The first equation gives \(a = \bar{y} - b\bar{x}\): the fitted line runs through the means. Substituting that into the second and solving:

\[b = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sum (x_i - \bar{x})^{2}}\]

Session 21 does this carefully. Here it only needs to show that OLS is the same optimization problem as the mean, with a slope added.

4. Rectangles to the integral, and the fundamental theorem

Slides: So Use More Rectangles, The Integral Is the Limit, The Fundamental Theorem.

The integral as a limit. Slice \([a,b]\) into \(n\) pieces of width \(\Delta x = (b-a)/n\), add the rectangles, then let \(n \to \infty\):

\[\sum_{i} f(x_i)\,\Delta x \;\longrightarrow\; \int_a^b f(x)\,dx\]

Part 1. Let \(A(x) = \int_a^x f(t)\,dt\). Push the right edge out by \(h\); the extra area is a thin strip of height about \(f(x)\) and width \(h\):

\[A(x + h) - A(x) \approx f(x)\,h \quad \Longrightarrow \quad \frac{A(x+h) - A(x)}{h} \approx f(x)\]

Let \(h \to 0\) and you have \(A'(x) = f(x)\).

That is the same difference quotient as derivation 1.

Part 2. If \(F' = f\), then \(\int_a^b f(x)\,dx = F(b) - F(a)\). Worked example:

\[\int_0^2 x^{2}\,dx = \left[\frac{x^{3}}{3}\right]_0^2 = \frac{8}{3} \approx 2.667\]

(2^3 / 3) - (0^3 / 3)
[1] 2.666667
integrate(function(x) x^2, lower = 0, upper = 2)$value
[1] 2.666667

Payoff: next class \(f\) becomes a density and \(A\) becomes its CDF, so \(F(x) = \int_{-\infty}^{x} f(t)\,dt\) and \(f(x) = F'(x)\).

You Try answers

1. \(V(S) = 30 + 8\ln(S)\), with \(S\) in $10,000s. What is \(dV/dS\)? Compare \(S = 5\) and \(S = 50\).

\[\frac{dV}{dS} = \frac{8}{S}\]

At \(S = 5\) ($50,000 spent): \(8/5 = 1.6\) points of vote share per extra $10,000. At \(S = 50\) ($500,000 spent): \(8/50 = 0.16\) points. Ten times smaller, because the ratio of marginal effects is just the inverse ratio of spending, \(50/5\).

2. Is \(V\) concave or convex? Where should the party send its last $10,000?

\(V'' = -8/S^{2} < 0\) for all \(S > 0\), so \(V\) is concave: diminishing returns. Since the marginal return \(8/S\) falls as \(S\) rises, the last $10,000 buys the most vote share in the race that has spent the least so far.