Integrals from Scratch

by Jason Kuma Updated 0 views

Every rectangle gets the area wrong. Infinitely many rectangles get the area exactly right.

Here is a strange way to measure a curved shape: fill the shape with rectangles. A rectangle has a flat top and a curve does not, so every rectangle gets the area a little wrong, however many you use. Yet calculus uses rectangles to find areas exactly. How can a pile of wrong answers add up to a right one?

Start with a shape that no school geometry formula covers: the region under the curve \(y = x^2\), from \(x = 0\) to \(x = 1\).

Drawing
The shaded region fits inside the 1-by-1 square and under the dashed diagonal.

The triangle under the dashed diagonal has area \(\tfrac12\), and the shaded region fits inside that triangle. So the shaded area is less than \(\tfrac12\). How much less?

Guess the area

Your move: guess the area under each of three curves, then watch rectangles score your guess.

Three curves, three guesses

On every curve, the rectangle total crept toward one number, yet even 1,024 rectangles missed that number by a little.

For \(y = x^2\), the rectangle totals close in on about 0.333. What is the true area?

  1. Exactly \(\tfrac13\)
  2. About 0.333, with no exact value
  3. A tiny bit more than \(\tfrac13\)
  4. No one can know for sure
Show answer

A. Exactly \(\tfrac13\)

Exactly \(\tfrac13\), not just close. The proof comes further down, and the proof is built from the same wrong rectangles.

How can wrong rectangles prove an exact answer? Slow the rectangles down and count the rectangles yourself.

Count the rectangles

Cut the stretch from 0 to 1 into equal strips. In each strip, stand a rectangle as tall as the curve at the strip's left edge. Add up the rectangles' areas, height times width.

Your move: drag the slider to add rectangles, or press Play, and watch the error fall toward zero.

Fill the curve with rectangles

The gap between a total and the true area is called the error. The error is 34% with 4 rectangles, and only 1.5% with 100.

Go from 10 rectangles to 20. What happens to the error?

  1. The error stays about the same
  2. The error halves
  3. The error drops to a quarter
  4. The error drops to zero
Show answer

B. The error halves

The error halves, from 14.5% to 7.4%. Double the rectangles again, to 40, and the error halves again, to 3.7%.

Why does the error halve? The answer hides in the thin slivers that the rectangles miss.

Where the error hides

Zoom in on one strip. The curve keeps rising across the strip, so the left rectangle falls short of the curve. A right rectangle, as tall as the curve at the strip's right edge, pokes above the curve.

Drawing
In one strip, the true area is more than the left rectangle and less than the right rectangle.

So the true area sits between two totals: all the left rectangles and all the right rectangles. How far apart are the two totals? Each right rectangle is a left rectangle plus an extra piece on top.

Your move: add strips with the slider and watch the column of extra pieces on the right: does the column get taller, or only thinner?

Slide the extra pieces into one column

The column is one strip wide, a width written \(\Delta x\). The column is as tall as the curve's total climb, \(f(b) - f(a)\), where \(a\) and \(b\) are the two ends of the region:

\[\text{right} - \text{left} = \big(f(b) - f(a)\big)\,\Delta x\]

For \(y = x^2\), the column is 1 tall and \(\tfrac1n\) wide, where \(n\) is the number of strips. The true area sits between the two totals, so the left total misses by less than \(\tfrac1n\). Double the strips, and the column's area halves, and so does the error.

Now try the sine arch, \(y = \sin x\) from 0 to \(\pi\). The arch rises, then falls. Which total is bigger: the left total or the right total?

  1. The left total
  2. The right total
  3. Neither: the two totals are equal
Show answer

C. Neither: the two totals are equal

Equal, for any number of strips. The arch starts and ends at height zero, so the column has no height: every piece gained on the way up is lost on the way down. Pick Sine arch in the widget above to watch.

Halving is slow, though. For six correct digits of \(\tfrac13\), left rectangles need about a million strips. Is there a smarter height to pick for each rectangle?

Measure at the middle

Try the height of the curve at the middle of each strip. On a rising curve, a middle rectangle sticks up above the curve on the strip's left half and falls short on the right half. The extra piece and the missing piece almost cancel.

Drawing
A middle rectangle: an extra piece on the left half, a missing piece on the right half, almost the same size.

In the rectangle widget, pick Middle and go from 10 rectangles to 20. What happens to the error now?

  1. The error halves, like before
  2. The error drops to a quarter
  3. The error drops to a tenth
  4. The error grows
Show answer

B. The error drops to a quarter

The error drops to a quarter, from 0.25% to 0.062%. With middle rectangles, each doubling of the strips cuts the error by four, not by two.

Correct digits as the rectangles double (y = x², 0 to 1)
Number of rectanglesLeft edgeMiddle
n=10.4771.079
n=20.6811.681
n=40.9412.283
n=81.2232.885
n=161.5143.487
n=321.8114.089
n=642.1094.692
n=1282.4095.294
n=2562.715.896
n=5123.0116.498
n=10243.3117.1
Each doubling of the rectangles adds about 0.3 correct digits to the left total and about 0.6 to the middle total. (Correct digits means −log₁₀ of the error.)

For six correct digits, about 400 middle rectangles do the work of a million left rectangles. Still, every middle total is a little wrong too. So how can anyone say the area is exactly \(\tfrac13\)?

From close to exact

Stop looking at any single total. Ask instead which number the totals close in on as the strips get thinner, with no end. First, name the parts: number the strips from 1 to \(n\), each \(\Delta x\) wide, and make strip \(i\) as tall as the curve at a chosen point \(x_i\) (the left edge, the right edge or the middle).

Drawing
One strip: height f(xᵢ), width Δx, so area f(xᵢ) × Δx.

Adding up height times width for every strip gives a Riemann sum:

\[S_n = \sum_{i=1}^{n} f(x_i)\,\Delta x, \qquad \Delta x = \frac{b-a}{n}\]

The number the Riemann sums close in on, as \(n\) grows without end, is the definite integral:

\[\int_a^b f(x)\,dx = \lim_{n\to\infty} \sum_{i=1}^{n} f(x_i)\,\Delta x\]

For a curve with no breaks or jumps, the left, right and middle sums all close in on that same number. Each sum is wrong; the limit is exact.

The proof: the area under \(y = x^2\) is exactly \(\tfrac13\)

Use right edges. With \(n\) strips between 0 and 1, each strip is \(\Delta x = \tfrac1n\) wide, and strip \(i\) ends at \(x_i = \tfrac in\).
The right sum is \(S_n = \sum_{i=1}^{n} \left(\tfrac in\right)^2 \cdot \tfrac1n = \tfrac{1}{n^3} \sum_{i=1}^{n} i^2\).
The first \(n\) square numbers add up to \(\tfrac{n(n+1)(2n+1)}{6}\). (Check with \(n = 3\): \(1 + 4 + 9 = 14\), and \(\tfrac{3 \cdot 4 \cdot 7}{6} = 14\).)
So \(S_n = \tfrac{(n+1)(2n+1)}{6n^2} = \tfrac13 + \tfrac{1}{2n} + \tfrac{1}{6n^2}\).
As \(n\) grows without end, \(\tfrac{1}{2n}\) and \(\tfrac{1}{6n^2}\) both shrink to 0. So \(\int_0^1 x^2\,dx = \tfrac13\), exactly.
The leftover, \(\tfrac{1}{2n} + \tfrac{1}{6n^2}\), is the right sum's error. The error is never zero for any \(n\), but the error's limit is zero.

The proof leaned on a formula for adding up square numbers, and most curves have no such formula. Is there another road to the exact area?

The plot twist

In the late 1600s, Isaac Newton and Gottfried Leibniz each found another road, one that links area to slope, the steepness of a curve. To see the link, let the region grow. Fix the left end at \(a\), let the right end \(x\) move, and call the area from \(a\) to \(x\) by the name \(A(x)\).

Picture sliding the right end \(x\) a little to the right. How fast does the area \(A(x)\) grow?

  1. As fast as the curve is tall at \(x\)
  2. As fast as the curve is steep at \(x\)
  3. At the same speed everywhere
Show answer

A. As fast as the curve is tall at \(x\)

As fast as the curve is tall. A small step \(h\) to the right adds one thin strip, \(h\) wide and about \(f(x)\) tall, so the area grows at the rate \(f(x)\).

Drawing
Move x by a small step h, and the area gains one thin strip, about f(x) tall.

The rate at which \(A(x)\) grows is the slope of \(A\). So the slope of the area is the height of the curve:

\[\frac{d}{dx}\int_a^x f(t)\,dt = f(x)\]

Your move: find the x where the shaded area peaks, and check that the two numbers under the plots always match. Area below the axis counts as negative.

The slope of the area is the height

The link hands over a shortcut. Find any function \(F\) whose slope is \(f\), called an antiderivative of \(f\). The area from \(a\) to \(b\) is then one subtraction:

\[\int_a^b f(x)\,dx = F(b) - F(a)\]

For \(y = x^2\), the function \(F(x) = \tfrac{x^3}{3}\) has slope \(x^2\). So the area from 0 to 1 is \(\tfrac{1^3}{3} - \tfrac{0^3}{3} = \tfrac13\): one line instead of a limit of sums.

Your turn. Use the shortcut to find the area under \(y = x^3\) from 0 to 2. Hint: \(F(x) = \tfrac{x^4}{4}\) has slope \(x^3\).

  1. 2
  2. 4
  3. 8
  4. 16
Show answer

B. 4

\(F(2) - F(0) = \tfrac{2^4}{4} - 0 = 4\), exactly. Rectangles would need thousands of strips just to get close to 4.

flowchart LR
  I["Integral<br>area under a curve"] <----> D["Derivative<br>slope of a curve"]
Each one undoes the other: two problems that turned out to be one. The link is called the Fundamental Theorem of Calculus.

So here is the answer to the opening puzzle. Every rectangle total is wrong, but the integral is not any one total. The integral is the one number all the totals close in on: for \(y = x^2\), exactly \(\tfrac13\), by the proof or by one subtraction.

For the AP exam

Ask Phy

  • Why does the middle-rectangle error shrink like \(1/n^2\) instead of \(1/n\)?
  • Why does \(F(b) - F(a)\) still work when part of the curve is below the axis?
  • How do I turn \(\lim_{n\to\infty} \sum_{i=1}^{n} \frac{3}{n}\left(1 + \frac{3i}{n}\right)^2\) back into an integral?