---
title: The definite integral
heading: From a sum of slices to an exact area
eyebrow: A5 · Lesson 42 · The definite integral
xp: 40
---

::: hook
Lesson 41 estimated accumulated charge by adding up thin slices of current. The estimate improves as the slices get thinner, and in the limit of infinitely many infinitely thin slices it becomes exact: the **definite integral**. This lesson makes that limit precise, computes one by hand to see the machinery work, and collects the rules that let you take integrals apart and put them back together.
:::

::: play
- The bars are a midpoint sum for $\int_0^2 x^2\,dx$ with $n$ slices. The exact area is $8/3 \approx 2.6667$.
- Increase $n$ and watch the sum converge. How does the error shrink when $n$ doubles?
:::
:::

```sim plot
view: graph
x: x = 0..2.2
y: y = 0..5
slider: n = 1..40 step 1 = 4
plot: x^2 | label: y = x²
plot: ((floor(x*n/2) + 0.5)*2/n)^2*(1 - step(x - 2)) | color: ch2 | label: midpoint slices | samples: 2000
readout: midpoint sum = 8/3 - 2/(3*n^2) | digits: 6
readout: error = -2/(3*n^2) | digits: 4
```

::: predict
## A midpoint sum for $\int_0^2 x^2\,dx$ has an error of 0.0417 with 4 slices. About what is the error with 8 slices?

- [ ] 0.0208
- [x] 0.0104
- [ ] 0.0026
- [ ] 0.0417

::: reveal
About 0.0104, a quarter. The midpoint rule's error goes as $1/n^2$: doubling the slices divides it by four. (The left and right sums from lesson 41 are cruder: their errors only halve.) In the limit, every reasonable choice of slices gives the same answer, $8/3$.
:::
:::

::: nameit
## Sums and sigma notation

A sum of many terms is written with $\Sigma$:

$$\sum_{k=1}^{n} a_k = a_1 + a_2 + \cdots + a_n$$

Three closed forms make hand computation possible:

$$\sum_{k=1}^n 1 = n \qquad \sum_{k=1}^n k = \frac{n(n+1)}{2} \qquad \sum_{k=1}^n k^2 = \frac{n(n+1)(2n+1)}{6}$$

## The definite integral

Split $[a, b]$ into $n$ slices of width $\Delta x = \frac{b - a}{n}$, pick a point $x_k^*$ in each, and form the **Riemann sum** $\sum f(x_k^*)\Delta x$. The definite integral is its limit:

$$\int_a^b f(x)\,dx = \lim_{n \to \infty}\sum_{k=1}^{n} f(x_k^*)\,\Delta x$$

For continuous $f$ the limit exists and doesn't depend on which points you pick.

**By hand, for $\int_0^1 x^2\,dx$:** with right endpoints $x_k = k/n$,

$$\sum_{k=1}^n \left(\frac{k}{n}\right)^2\frac{1}{n} = \frac{1}{n^3}\cdot\frac{n(n+1)(2n+1)}{6} \to \frac{2}{6} = \frac{1}{3}$$

The fundamental theorem (lesson 43) will make this a one-liner, but this is what it's shortcutting.

## Signed area and properties

Area below the axis counts as negative: $\int_0^{2\pi}\sin x\,dx = 0$. A current that flows both ways delivers a **net** charge.

- **Linearity:** $\int (af + bg) = a\int f + b\int g$.
- **Additivity:** $\int_a^b f + \int_b^c f = \int_a^c f$.
- **Reversing:** $\int_b^a f = -\int_a^b f$, and $\int_a^a f = 0$.
- **Bounds:** if $m \le f \le M$ on $[a, b]$, then $m(b - a) \le \int_a^b f \le M(b - a)$.
:::

::: example
## Compute $\displaystyle\sum_{k=1}^{20}(3k + 2)$.

::: solution
1. **Split the sum.**
   $$\sum_{k=1}^{20}(3k + 2) = 3\sum k + \sum 2$$
2. **Sum each part.**
   $$\begin{aligned} 3\sum k + \sum 2 &= 3 \cdot \frac{20 \cdot 21}{2} + 2 \cdot 20 \\ &= 630 + 40 \\ &= 670 \end{aligned}$$

**Answer:** the sum is 670.
:::
:::

::: example
## Find $\int_0^2 x^2\,dx$ as a limit of right-endpoint sums.

::: solution
1. **Set up the slices.** $\Delta x = 2/n$ and $x_k = 2k/n$, so the right sum is
   $$S_n = \sum_{k=1}^n \frac{4k^2}{n^2}\cdot\frac{2}{n}$$
2. **Use the sum of squares.**
   $$\begin{aligned} S_n &= \frac{8}{n^3}\cdot\frac{n(n+1)(2n+1)}{6} \\ &= \frac{4(n+1)(2n+1)}{3n^2} \end{aligned}$$
3. **Let $n \to \infty$.**
   $$S_n \to \frac{8}{3}$$
4. **Check with numbers.** At $n = 10$ the sum is 3.08, at $n = 100$ it's 2.707: closing in on 2.667 from above, since right endpoints overestimate a rising function.

**Answer:** $\int_0^2 x^2\,dx = \frac{8}{3}$, about 2.667.
:::
:::

::: example
## Use $\sum_{k=1}^n k^2 = \frac{n(n + 1)(2n + 1)}{6}$ to find the right-endpoint sum for $\int_0^1 x^2\,dx$ with $n = 100$.

::: solution
1. **Write the sum.** With width $1/n$ and heights $(k/n)^2$:
   $$\begin{aligned} S_n &= \frac{1}{n^3}\sum k^2 \\ &= \frac{(n + 1)(2n + 1)}{6n^2} \end{aligned}$$
2. **Put in $n = 100$.**
   $$\begin{aligned} S_{100} &= \frac{101 \times 201}{60\,000} \\ &= 0.338\,35 \end{aligned}$$
3. **Compare with the exact area.** The exact area is $\tfrac13$, so the error is 0.0050, about $\frac{1}{2n}$: right endpoints overshoot a rising curve by about half a slice per unit of rise.

**Answer:** the right-endpoint sum with $n = 100$ is 0.338 35.
:::
:::

::: check
given: n = 10 | 20 | 50; a = 2 | 3; b = 1 | 5
answer: a*n*(n + 1)/2 + b*n

## Compute $\displaystyle\sum_{k=1}^{\given{n}}(\given{a}k + \given{b})$.

::: right
Right. $\given{a}\frac{n(n+1)}{2} + \given{b}n$ = {answer}.
:::

::: misses
- [a*n*(n + 1)/2 + b] The constant term is added {n} times.
- [a*n^2/2 + b*n] $\sum k = \frac{n(n+1)}{2}$, not $\frac{n^2}{2}$.
- [any] Not yet. Split into $a\sum k + \sum b$.
:::
:::

::: check
given: n = 4 | 5 | 10
answer: (n + 1)*(2*n + 1)/(6*n^2)
tolerance: 0.1%

## Using right endpoints and $n$ = {n} slices, what is the Riemann sum for $\int_0^1 x^2\,dx$?

::: right
Right. $\frac{(n+1)(2n+1)}{6n^2}$ = {answer}, a little above the exact $\frac{1}{3}$.
:::

::: misses
- [1/3] That's the limit. The question asks for the sum with {n} slices.
- [(n - 1)*(2*n - 1)/(6*n^2)] That's the left-endpoint sum.
- [any] Not yet. $\frac{1}{n^3}\sum_{k=1}^n k^2$.
:::
:::

::: check
given: a = 2 | 5; b = 3 | 7; I1 = 4 | 6; I2 = 1 | 3
answer: a*I1 + b*I2

## $\int_0^1 f = \given{I1}$ and $\int_0^1 g = \given{I2}$. What is $\int_0^1 (\given{a}f + \given{b}g)$?

::: right
Right. Linearity: $\given{a}\cdot\given{I1} + \given{b}\cdot\given{I2}$ = {answer}.
:::

::: misses
- [(a + b)*(I1 + I2)] Each constant multiplies only its own integral.
- [any] Not yet. Integrals split over sums and constants come out.
:::
:::

::: check
given: I1 = 3 | 5; I2 = -2 | 4
answer: I1 + I2

## $\int_0^2 f = \given{I1}$ and $\int_2^5 f = \given{I2}$. What is $\int_0^5 f$?

::: right
Right. Additivity: {answer}.
:::

::: misses
- [I1 - I2] The intervals join end to end: add.
- [any] Not yet. $\int_0^2 + \int_2^5 = \int_0^5$.
:::
:::

::: check
kind: choice

## A current $i(t) = 2\sin(100\pi t)$ A flows for 20 ms, exactly one cycle. What net charge passes?

- [x] 0 C
- [ ] 2 C
- [ ] 0.0127 C
- [ ] 40 mC

::: right
Right. The positive half-cycle and the negative half-cycle cancel: the signed area over a full cycle is zero.
:::

::: misses
- [3] That's the charge in one half-cycle, $\int_0^{10\text{ ms}}2\sin(100\pi t)\,dt = 4/(100\pi)$. Over a full cycle the second half flows back.
- [any] Count area below the axis as negative.
:::
:::

::: check
given: m = 1 | 2; M = 4 | 6; a = 0 | 1; b = 3 | 5
answer: M*(b - a)

## On $[\given{a}, \given{b}]$, $\given{m} \le f(x) \le \given{M}$. What is the largest $\int_{\given{a}}^{\given{b}} f$ could be?

::: right
Right. At most $M(b - a)$ = {answer}.
:::

::: misses
- [m*(b - a)] That's the smallest it could be.
- [M] Multiply by the interval's length.
- [any] Not yet. $\int f \le M(b - a)$.
:::
:::

::: check
kind: parts
given: a = 1 | 2 | 3; n = 4 | 10 | 100

## Estimate $\int_0^{\given{a}} x\,dx$ with a right-endpoint sum of {n} slices.

::: part
answer: a^2*(n + 1)/(2*n)
tolerance: 0.5%

### What is the sum?

::: misses
- [a^2*(n - 1)/(2*n)] That's the left-endpoint sum.
- [any] Width $a/n$, heights $ka/n$, and $\sum k = n(n + 1)/2$.
:::
:::

::: part
answer: a^2/2
tolerance: 0.5%

### What is the exact integral?

::: misses
- [any] The triangle under $y = x$.
:::
:::

::: part
answer: a^2/(2*n)
tolerance: 0.5%

### By how much does the sum overshoot?

::: misses
- [any] Subtract: it shrinks as $1/n$.
:::
:::
:::

::: check
kind: derivation
vars: b = 0.5..3, n = 1..200

## Find $\int_0^b x^2\,dx$ as the limit of right-endpoint sums.

::: step
answer: b^3*(n + 1)*(2*n + 1)/(6*n^2)

### With $n$ slices of width $b/n$ and heights $(kb/n)^2$, use $\sum k^2 = \frac{n(n + 1)(2n + 1)}{6}$ to write the sum.
:::

::: step
answer: b^3/3

### Let $n \to \infty$.
:::

::: right
Right. The sums close in on $b^3/3$, which the fundamental theorem gives directly.
:::
:::

::: explain
## Why does a Riemann sum get closer to the exact integral as the slices get thinner?

::: model
Each slice approximates the area under the curve by a rectangle, and the error in a slice comes from how much the function changes across it. Thinner slices mean the function changes less across each one, so each rectangle fits better. Even though there are more slices, the total error shrinks: for a smooth function it goes as the slice width (left or right sums) or its square (midpoint sums). In the limit the sum equals the area exactly.
:::
:::

::: practice

::: check
given: n = 10 | 30 | 100
answer: n*(n + 1)*(2*n + 1)/6

## Compute $\displaystyle\sum_{k=1}^{\given{n}} k^2$.

::: misses
- [n^3/3] Use the exact formula, $\frac{n(n+1)(2n+1)}{6}$.
- [any] $\frac{n(n+1)(2n+1)}{6}$.
:::
:::

::: check
given: I = 2..15 int
answer: -I

## $\int_1^4 f = \given{I}$. What is $\int_4^1 f$?

::: misses
- [I] Reversing the limits flips the sign.
- [any] $\int_b^a = -\int_a^b$.
:::
:::

::: check
given: n = 4 | 8 | 16
answer: 8/3 - 2/(3*n^2)
tolerance: 0.01%

## The midpoint sum for $\int_0^2 x^2\,dx$ with $n$ slices is $\frac{8}{3} - \frac{2}{3n^2}$. What is it for $n$ = {n}?

::: misses
- [8/3] That's the limit.
- [any] Substitute $n$.
:::
:::
:::
