---
title: Area and the Definite Integral
module: Integrals
moduleNumber: 4
lessonNumber: 1
order: 401
summary: >
  The area under a curve is defined as a limit of sums of rectangle areas. The
  same limit — a Riemann sum taken as the mesh shrinks to zero — defines the
  definite integral, a single number measuring signed area, total distance, and
  every accumulated quantity built the same way. Its properties, comparison bounds,
  and reading as net area follow directly from the limit.
topics: [Integrals]
sources:
  - book: Stewart
    ref: "Ch. 4 — Integrals; §4.1 Areas and Distances"
  - book: Stewart
    ref: "Ch. 4; §4.2 The Definite Integral"
draft: false
---

Differential calculus began with the slope of a tangent and answered it with a
limit of secant slopes. Integral calculus begins with a different question whose
answer is also a limit. Given a
function $f$ on $[a, b]$, what is the area of the region under its graph? For a
rectangle or a triangle the answer is elementary. For a region with a curved
upper boundary there is no formula, so area itself has to be _defined_, and the
definition is a limit.

Defining area precisely isolates one type of limit: a sum of many small
contributions, taken as each contribution shrinks. The same limit recurs whenever
a quantity accumulates from a varying rate. Distance from velocity, mass from
density, work from force all reduce to it. That limit is the **definite integral**.

## Approximating an area by rectangles

Let $f$ be continuous and nonnegative on $[a, b]$, and let $S$ be the region
bounded above by $y = f(x)$, below by the $x$-axis, and on the sides by the lines
$x = a$ and $x = b$. To estimate the area of $S$, cut $[a, b]$ into $n$
subintervals of equal width

$$
\Delta x = \frac{b - a}{n},
$$

and over each subinterval erect a rectangle whose height is a value of $f$ on that
subinterval. Choosing the height at the right endpoint $x_i = a + i\,\Delta x$
gives the **right-endpoint sum**

$$
R_n = f(x_1)\,\Delta x + f(x_2)\,\Delta x + \cdots + f(x_n)\,\Delta x.
$$

Choosing the left endpoint gives $L_n$; choosing the midpoint gives $M_n$. Each
is an approximation to the area, exact only in the limit.

$$
% caption: Right-endpoint rectangles under $y = x^2$ on $[0,1]$ for $n = 4$ and
% $n = 8$; refining the partition drives the total rectangle area toward the true
% area $1/3$.
\begin{tikzpicture}[scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
% ---- left panel: n = 4 ----
\begin{scope}
  \draw[->, black] (-0.2,0) -- (4.4,0) node[right, black!70] {$x$};
  \draw[->, black] (0,-0.2) -- (0,3.4) node[above, black!70] {$y$};
  \foreach \i in {1,2,3,4} {
    \pgfmathsetmacro{\xa}{(\i-1)*1.0}
    \pgfmathsetmacro{\xr}{\i*1.0}
    \pgfmathsetmacro{\h}{(\i/4)*(\i/4)*3.0}
    \fill[acc!12] (\xa,0) rectangle (\xr,\h);
    \draw[acc] (\xa,0) rectangle (\xr,\h);
  }
  \draw[black, very thick, domain=0:4, samples=60, smooth] plot (\x, {(\x/4)*(\x/4)*3.0});
  \node[black!70, anchor=north] at (2.0,-0.25) {$n = 4$};
  \node[black, anchor=south east] at (4.2,2.9) {$y = x^2$};
\end{scope}
% ---- right panel: n = 8 ----
\begin{scope}[xshift=6cm]
  \draw[->, black] (-0.2,0) -- (4.4,0) node[right, black!70] {$x$};
  \draw[->, black] (0,-0.2) -- (0,3.4) node[above, black!70] {$y$};
  \foreach \i in {1,...,8} {
    \pgfmathsetmacro{\xa}{(\i-1)*0.5}
    \pgfmathsetmacro{\xr}{\i*0.5}
    \pgfmathsetmacro{\h}{(\i/8)*(\i/8)*3.0}
    \fill[acc!12] (\xa,0) rectangle (\xr,\h);
    \draw[acc] (\xa,0) rectangle (\xr,\h);
  }
  \draw[black, very thick, domain=0:4, samples=60, smooth] plot (\x, {(\x/4)*(\x/4)*3.0});
  \node[black!70, anchor=north] at (2.0,-0.25) {$n = 8$};
\end{scope}
\end{tikzpicture}
$$

For $f(x) = x^2$ on $[0, 1]$ the two estimates bracket the area from opposite
sides, because $x^2$ is increasing: the left-endpoint rectangles sit under the
curve and the right-endpoint rectangles poke above it. A short computation with
$n = 4$ gives

$$
L_4 = 0.21875, \qquad R_4 = 0.46875,
$$

so $0.21875 < A < 0.46875$. Doubling to $n = 8$ tightens this to
$0.2734 < A < 0.3984$, and $n = 1000$ traps $A$ between $0.33283$ and $0.33383$.
Both sequences close on the same value, computed exactly below to be $\tfrac13$.

> **Definition (Area under a curve).** For $f$ continuous and nonnegative on
> $[a, b]$, the **area** of the region under $y = f(x)$ is
> $$
> A = \lim_{n \to \infty} R_n = \lim_{n \to \infty} \sum_{i=1}^{n} f(x_i)\,\Delta x,
> $$
> the limit of the total rectangle area as the number of rectangles grows without
> bound. The limit exists whenever $f$ is continuous, and the same value results
> from left endpoints, right endpoints, or any sample points.

### Evaluating the limit for a power

The definition is only useful if the limit can sometimes be computed. For
$f(x) = x^2$ on $[0, 1]$ the right endpoints are $x_i = i/n$ and $\Delta x = 1/n$,
so

$$
R_n = \sum_{i=1}^{n} \parens{\frac{i}{n}}^2 \frac{1}{n}
    = \frac{1}{n^3} \sum_{i=1}^{n} i^2.
$$

The sum of the first $n$ squares has a closed form,[^sumsquares]

$$
\sum_{i=1}^{n} i^2 = \frac{n(n+1)(2n+1)}{6},
$$

and substituting collapses the whole expression to a ratio of polynomials in $n$:

$$
R_n = \frac{1}{n^3} \cdot \frac{n(n+1)(2n+1)}{6}
    = \frac{(n+1)(2n+1)}{6n^2}
    = \frac{1}{6}\parens{1 + \frac1n}\parens{2 + \frac1n}.
$$

As $n \to \infty$ the two correction terms vanish:

$$
A = \lim_{n \to \infty} R_n
  = \frac{1}{6}(1)(2) = \frac13.
$$

The lower sums $L_n$ approach the same $\tfrac13$ from below, confirming the
estimate. Computing an area this way is exact but laborious; it requires a summation
formula tailored to the integrand. The
[Fundamental Theorem](/calculus/integrals/the-fundamental-theorem-of-calculus)
removes that labor entirely, but the limit is what the answer _means_.

A cubic integrand pushes the same method one step further and uses two power-sum
identities at once, $\sum i^3 = \bigl[n(n+1)/2\bigr]^2$ and $\sum i = n(n+1)/2$.

> **Worked example.** Evaluate $\int_0^3 (x^3 - 6x)\,\d x$ directly from the
> definition, taking right endpoints.
>
> With $n$ subintervals, $\Delta x = 3/n$ and $x_i = 3i/n$. The Riemann sum
> separates into two power sums:
> $$
> R_n = \sum_{i=1}^n \Bigl[\parens{\tfrac{3i}{n}}^3 - 6\parens{\tfrac{3i}{n}}\Bigr]\frac{3}{n}
>     = \frac{81}{n^4}\sum_{i=1}^n i^3 - \frac{54}{n^2}\sum_{i=1}^n i.
> $$
> Substituting the two identities,
> $$
> R_n = \frac{81}{n^4}\cdot\frac{n^2(n+1)^2}{4} - \frac{54}{n^2}\cdot\frac{n(n+1)}{2}
>     = \frac{81}{4}\parens{1 + \frac1n}^2 - 27\parens{1 + \frac1n}.
> $$
> As $n \to \infty$ the correction terms vanish, leaving
> $$
> \int_0^3 (x^3 - 6x)\,\d x = \frac{81}{4} - 27 = -\frac{27}{4} = -6.75.
> $$
> The value is negative because $x^3 - 6x$ spends most of $[0, 3]$ below the axis.

### Sample points and sigma notation

Nothing in the construction requires the height to come from an endpoint. Let
$x_i^\ast$ (also written $c_i$) be _any_ point in the $i$-th subinterval
$[x_{i-1}, x_i]$, called a **sample point**, and the sum
$\sum_i f(x_i^\ast)\,\Delta x$ still approximates the area. Endpoints and midpoints are the convenient choices, but the limit is
independent of the choice.

$$
% caption: A partition of $[a,b]$ into $n$ subintervals of width $\Delta x$, with
% an arbitrary sample point $c_i = x_i^\ast$ in each; the shaded rectangle has
% height $f(c_i)$ and width $\Delta x$.
\begin{tikzpicture}[scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\draw[->, black] (-0.2,0) -- (9.2,0) node[right, black!70] {$x$};
\draw[->, black] (0,-0.2) -- (0,3.6) node[above, black!70] {$y$};
\draw[black, very thick, domain=0.2:8.6, samples=80, smooth]
  plot (\x, {1.1 + 1.4*sin(\x*32) + 0.10*\x});
% partition points
\foreach \x in {0.8, 2.2, 3.6, 5.0, 6.4, 7.8}
  \draw[black] (\x,0.08) -- (\x,-0.08);
\node[black!70, anchor=north, font=\footnotesize] at (0.8,-0.12) {$a$};
\node[black!70, anchor=north, font=\footnotesize] at (7.8,-0.12) {$b$};
% highlighted rectangle on the i-th subinterval
\pgfmathsetmacro{\xs}{4.35}
\pgfmathsetmacro{\hh}{1.1 + 1.4*sin(\xs*32) + 0.10*\xs}
\fill[acc!12] (3.6,0) rectangle (5.0,\hh);
\draw[acc, thick] (3.6,0) rectangle (5.0,\hh);
\fill[acc] (\xs,\hh) circle (1.6pt);
\draw[acc, dashed] (\xs,0) -- (\xs,\hh);
\node[acc, anchor=north, font=\footnotesize] at (\xs,-0.12) {$c_i$};
\node[acc, anchor=west, font=\footnotesize] at (5.05,\hh) {$f(c_i)$};
\draw[<->, black] (3.6,-0.55) -- (5.0,-0.55);
\node[black!70, anchor=north, font=\footnotesize] at (4.3,-0.55) {width};
\end{tikzpicture}
$$

Sigma notation compresses these sums. Writing the area three equivalent ways,

$$
A = \lim_{n \to \infty} \sum_{i=1}^{n} f(x_i)\,\Delta x
  = \lim_{n \to \infty} \sum_{i=1}^{n} f(x_{i-1})\,\Delta x
  = \lim_{n \to \infty} \sum_{i=1}^{n} f(x_i^\ast)\,\Delta x,
$$

with right endpoints, left endpoints, and arbitrary samples respectively.

## The distance problem gives the same limit

An object moves along a line with velocity $v = f(t) \ge 0$ on $a \le t \le b$. If
the velocity were constant the distance would be velocity times time. It is not
constant, so partition the time interval, treat the velocity as approximately
constant on each short piece, and add up the piecewise distances. With readings at
$t_0, t_1, \dots, t_n$ spaced $\Delta t$ apart, the distance over $[t_{i-1}, t_i]$
is about $f(t_{i-1})\,\Delta t$, and the total is

$$
d \approx \sum_{i=1}^{n} f(t_{i-1})\,\Delta t.
$$

The estimate sharpens as the readings grow more frequent, and in the limit

$$
d = \lim_{n \to \infty} \sum_{i=1}^{n} f(t_i)\,\Delta t.
$$

This is the area limit with $f$ a velocity and $\Delta x$ a $\Delta t$: distance
traveled equals the area under the velocity graph. Area, distance, mass, and work
share one structure — partition, sample, sum, take the limit — which the definite
integral captures once and for all.

$$
% caption: A step-function estimate of distance: each rectangle's area,
% $f(t_{i-1})\,\Delta t$, is the distance covered in one time interval at the
% velocity read at its left endpoint.
\begin{tikzpicture}[scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\draw[->, black] (-0.2,0) -- (8.6,0) node[right, black!70] {$t$};
\draw[->, black] (0,-0.2) -- (0,3.4) node[above, black!70] {$v$};
% velocity curve
\draw[black, very thick, domain=0:8, samples=80, smooth]
  plot (\x, {1.4 + 1.3*sin(\x*20+20) + 0.05*\x});
% left-endpoint step rectangles, width 1.0
\foreach \i in {0,1,2,3,4,5,6,7} {
  \pgfmathsetmacro{\xa}{\i*1.0}
  \pgfmathsetmacro{\xb}{(\i+1)*1.0}
  \pgfmathsetmacro{\h}{1.4 + 1.3*sin(\xa*20+20) + 0.05*\xa}
  \fill[acc!10] (\xa,0) rectangle (\xb,\h);
  \draw[acc] (\xa,0) rectangle (\xb,\h);
}
\node[black, anchor=south west, font=\footnotesize] at (5.4,3.0) {$v = f(t)$};
\draw[<->, black] (0,-0.5) -- (1.0,-0.5);
\node[black!70, anchor=north, font=\footnotesize] at (0.5,-0.5) {width};
\end{tikzpicture}
$$

## The definite integral

The limit of Riemann sums is given its own name and symbol.

> **Definition (Definite integral).** Let $f$ be defined on $[a, b]$. Partition the
> interval into $n$ subintervals of width $\Delta x = (b-a)/n$ with sample points
> $x_i^\ast \in [x_{i-1}, x_i]$. The **definite integral of $f$ from $a$ to $b$** is
> $$
> \int_a^b f(x)\,\d x = \lim_{n \to \infty} \sum_{i=1}^{n} f(x_i^\ast)\,\Delta x,
> $$
> provided this limit exists and gives the same value for every choice of sample
> points. When it does, $f$ is **integrable** on $[a, b]$.

The pieces of the notation are named:

- **Integral sign** $\int$: an elongated S, chosen by Leibniz because the integral
  is a limit of sums.
- **Integrand** $f(x)$: the function being integrated.
- **Limits of integration** $a$ (lower) and $b$ (upper).
- **Differential** $\d x$: for now it carries no value of its own; it marks $x$ as the
  variable of integration and corresponds to the $\Delta x$ in the sum.

The sum $\sum_{i=1}^{n} f(x_i^\ast)\,\Delta x$ is a **Riemann sum**, after Bernhard
Riemann. A definite integral is the number a Riemann sum approaches; equivalently,
a Riemann sum approximates the integral to any accuracy once $n$ is large enough.

Two facts make the definition workable in practice. First, the integral is a
number, not a function of $x$ — the variable is a placeholder, so
$\int_a^b f(x)\,\d x = \int_a^b f(t)\,\d t$. Second, continuity is enough to guarantee
the limit exists.

> **Theorem (Integrability of continuous functions).** If $f$ is continuous on
> $[a, b]$, or has only finitely many jump discontinuities there, then $f$ is
> integrable on $[a, b]$.

For an integrable function the sample points may as well be right endpoints, which
simplifies calculation:

$$
\int_a^b f(x)\,\d x = \lim_{n \to \infty} \sum_{i=1}^{n} f(x_i)\,\Delta x,
\qquad \Delta x = \frac{b-a}{n}, \quad x_i = a + i\,\Delta x.
$$

A limit of sums can be read backwards as an integral. The limit
$\lim_{n\to\infty}\sum_{i=1}^n (x_i^3 + x_i \sin x_i)\,\Delta x$ over $[0,\pi]$ is,
by matching against the definition, exactly $\int_0^\pi (x^3 + x\sin x)\,\d x$; the
integrand is read straight off the summand.

## The integral as net area

When $f \ge 0$ the integral is the area under the graph. When $f$ dips below the
axis the Riemann sum subtracts: a rectangle below the axis has negative height
$f(x_i^\ast) < 0$, so it contributes a negative amount. The integral therefore
measures **net area** — area above the axis counted positive, area below counted
negative.

> **Net area.** If $A_1$ is the area of the region above the $x$-axis and below the
> graph, and $A_2$ the area below the axis and above the graph, then
> $$
> \int_a^b f(x)\,\d x = A_1 - A_2.
> $$

$$
% caption: The integral of a sign-changing function is the area above the axis
% minus the area below it; here the region $A_1$ adds and $A_2$ subtracts.
\begin{tikzpicture}[scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\definecolor{neg}{HTML}{B5651D}
\draw[->, black] (-0.2,0) -- (8.6,0) node[right, black!70] {$x$};
\draw[->, black] (0,-1.6) -- (0,2.4) node[above, black!70] {$y$};
% f(x) = 1.6*sin((3.0 - x)*75): zeros at x = 0.6, 3.0, 5.4, 7.8
\begin{scope}
  \clip (0.6,0) rectangle (3.0,2.2);
  \fill[acc!14, domain=0.6:7.8, samples=120, smooth]
    plot (\x, {1.6*sin((3.0-\x)*75)}) -- (7.8,0) -- (0.6,0) -- cycle;
\end{scope}
\begin{scope}
  \clip (3.0,-1.6) rectangle (5.4,0);
  \fill[neg!16, domain=0.6:7.8, samples=120, smooth]
    plot (\x, {1.6*sin((3.0-\x)*75)}) -- (7.8,0) -- (0.6,0) -- cycle;
\end{scope}
\begin{scope}
  \clip (5.4,0) rectangle (7.8,2.2);
  \fill[acc!14, domain=0.6:7.8, samples=120, smooth]
    plot (\x, {1.6*sin((3.0-\x)*75)}) -- (7.8,0) -- (0.6,0) -- cycle;
\end{scope}
\draw[black, very thick, domain=0.6:7.8, samples=140, smooth]
  plot (\x, {1.6*sin((3.0-\x)*75)});
\node[acc, font=\footnotesize] at (1.8,0.7) {$A_1$};
\node[neg, font=\footnotesize] at (4.2,-0.7) {$A_2$};
\node[acc, font=\footnotesize] at (6.6,0.7) {$A_1$};
\node[black, anchor=south, font=\footnotesize] at (3.0,1.95) {$y = f(x)$};
\end{tikzpicture}
$$

For example, $\int_0^3 (x^3 - 6x)\,\d x = -6.75$: the function is negative over most
of $[0, 3]$, so the region below the axis outweighs the sliver above it, and the
integral comes out negative even though it is built from "areas."

## Properties of the definite integral

Before doing any evaluation, two conventions extend the definition to
non-increasing limits. Reversing the endpoints flips $\Delta x$ and hence the sign;
equal endpoints give a degenerate partition of width zero:

$$
\int_b^a f(x)\,\d x = -\int_a^b f(x)\,\d x,
\qquad
\int_a^a f(x)\,\d x = 0.
$$

The following properties all descend from the definition and the fact that a limit
of sums respects sums and constant factors. Take $f$ and $g$ integrable.

| # | Property | Reading |
| --- | --- | --- |
| 1 | $\displaystyle\int_a^b c\,\d x = c(b-a)$ | integral of a constant is $c$ times the width |
| 2 | $\displaystyle\int_a^b [f + g]\,\d x = \int_a^b f\,\d x + \int_a^b g\,\d x$ | integral of a sum is the sum of integrals |
| 3 | $\displaystyle\int_a^b c f\,\d x = c\int_a^b f\,\d x$ | a constant factor comes outside |
| 4 | $\displaystyle\int_a^b [f - g]\,\d x = \int_a^b f\,\d x - \int_a^b g\,\d x$ | integral of a difference splits |
| 5 | $\displaystyle\int_a^c f\,\d x + \int_c^b f\,\d x = \int_a^b f\,\d x$ | adjacent intervals join |

Property 5 is the additive law over subintervals: the area from $a$ to $c$ plus the
area from $c$ to $b$ is the area from $a$ to $b$. It holds for any ordering of
$a, b, c$ once the sign conventions above are in force. As a worked instance, if
$\int_0^{10} f = 17$ and $\int_0^8 f = 12$, then

$$
\int_8^{10} f(x)\,\d x = \int_0^{10} f(x)\,\d x - \int_0^8 f(x)\,\d x = 17 - 12 = 5.
$$

### Comparison properties

Three more properties compare _sizes_ and require $a \le b$.

- **Nonnegativity.** If $f(x) \ge 0$ on $[a, b]$, then $\int_a^b f\,\d x \ge 0$.
- **Monotonicity.** If $f(x) \ge g(x)$ on $[a, b]$, then
  $\int_a^b f\,\d x \ge \int_a^b g\,\d x$ — a bigger integrand has a bigger integral.
- **Bounding.** If $m \le f(x) \le M$ on $[a, b]$, then
  $$
  m(b - a) \le \int_a^b f(x)\,\d x \le M(b - a).
  $$

Monotonicity orders two integrals without evaluating either.

> **Worked example.** Order $\int_0^1 x^2\,\d x$ and $\int_0^1 x^3\,\d x$ without
> computing them.
>
> On $[0, 1]$ every $x$ satisfies $0 \le x \le 1$, so $x^3 \le x^2$. Monotonicity
> then gives $\int_0^1 x^3\,\d x \le \int_0^1 x^2\,\d x$. The exact values $\tfrac14$
> and $\tfrac13$ confirm the inequality.

The bounding property is the quickest way to estimate an integral without any
summation. The integral is trapped between the areas of two rectangles spanning
$[a, b]$: one of height $m$, the minimum of $f$, and one of height $M$, the maximum.

$$
% caption: The bounding property traps $\int_a^b f\,dx$ between the rectangle of
% height $m$ (the minimum of $f$) and the rectangle of height $M$ (the maximum),
% both of width $b - a$.
\begin{tikzpicture}[scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\draw[->, black] (-0.2,0) -- (6.6,0) node[right, black!70] {$x$};
\draw[->, black] (0,-0.2) -- (0,3.7) node[above, black!70] {$y$};
% M rectangle (light) and m rectangle (lighter), a=1, b=5
\fill[acc!7] (1,0) rectangle (5,3.1);
\fill[acc!16] (1,0) rectangle (5,1.05);
\draw[acc!55] (1,3.1) -- (5,3.1);
\draw[acc] (1,1.05) -- (5,1.05);
% curve between m and M
\draw[black, very thick, domain=1:5, samples=80, smooth]
  plot (\x, {1.9 + 0.9*sin((\x-1)*45 - 20)});
\draw[black] (1,0.08) -- (1,-0.08) node[below, black!70, font=\footnotesize] {$a$};
\draw[black] (5,0.08) -- (5,-0.08) node[below, black!70, font=\footnotesize] {$b$};
\node[acc, anchor=east, font=\footnotesize] at (-0.05,3.1) {$M$};
\node[acc, anchor=east, font=\footnotesize] at (-0.05,1.05) {$m$};
\node[black, anchor=south, font=\footnotesize] at (3,3.15) {$y = f(x)$};
\end{tikzpicture}
$$

> **Worked example.** Bound $\int_1^4 \sqrt{x}\,\d x$ without evaluating it.
>
> The integrand $\sqrt{x}$ is increasing on $[1, 4]$, so its minimum is
> $m = \sqrt1 = 1$ and its maximum is $M = \sqrt4 = 2$. With $b - a = 3$, the
> bounding property gives
> $$
> 1 \cdot 3 \le \int_1^4 \sqrt{x}\,\d x \le 2 \cdot 3,
> \qquad\text{that is}\qquad
> 3 \le \int_1^4 \sqrt{x}\,\d x \le 6.
> $$
> The exact value $\tfrac{14}{3} \approx 4.67$, found later by the Fundamental
> Theorem, lies inside these bounds.

## The Midpoint Rule

When a numerical estimate is the goal rather than an exact limit, midpoints beat
endpoints. Take the sample point $\bar{x}_i = \tfrac12(x_{i-1} + x_i)$ at the center
of each subinterval.

> **Midpoint Rule.**
> $$
> \int_a^b f(x)\,\d x \approx \Delta x\,\bigl[f(\bar{x}_1) + f(\bar{x}_2) + \cdots + f(\bar{x}_n)\bigr],
> \qquad \Delta x = \frac{b - a}{n}.
> $$

$$
% caption: Midpoint rectangles: each height is $f(\bar{x}_i)$ sampled at the
% center of its subinterval, so the overshoot on one half offsets the undershoot
% on the other.
\begin{tikzpicture}[scale=1.0]
\definecolor{acc}{HTML}{4A6FA5}
\draw[->, black] (-0.2,0) -- (8.6,0) node[right, black!70] {$x$};
\draw[->, black] (0,-0.2) -- (0,3.4) node[above, black!70] {$y$};
\draw[black, very thick, domain=0.3:8.2, samples=90, smooth]
  plot (\x, {1.0 + 0.9*sin(\x*26 + 30) + 0.12*\x});
\foreach \i in {0,1,2,3,4,5} {
  \pgfmathsetmacro{\xa}{0.6 + \i*1.2}
  \pgfmathsetmacro{\xb}{0.6 + (\i+1)*1.2}
  \pgfmathsetmacro{\xm}{0.6 + (\i+0.5)*1.2}
  \pgfmathsetmacro{\hh}{1.0 + 0.9*sin(\xm*26 + 30) + 0.12*\xm}
  \fill[acc!11] (\xa,0) rectangle (\xb,\hh);
  \draw[acc] (\xa,0) rectangle (\xb,\hh);
  \fill[acc] (\xm,\hh) circle (1.3pt);
}
\pgfmathsetmacro{\xmone}{1.2}
\pgfmathsetmacro{\hone}{1.0 + 0.9*sin(\xmone*26 + 30) + 0.12*\xmone}
\draw[acc, dashed] (\xmone,0) -- (\xmone,\hone);
\node[acc, anchor=north, font=\footnotesize] at (\xmone,-0.12) {$\bar{x}_1$};
\node[black!70, anchor=north, font=\footnotesize] at (0.6,-0.12) {$a$};
\node[black!70, anchor=north, font=\footnotesize] at (7.8,-0.12) {$b$};
\node[black, anchor=south west, font=\footnotesize] at (5.6,3.0) {$y = f(x)$};
\end{tikzpicture}
$$

A midpoint rectangle overshoots on one half of its subinterval and undershoots on
the other, so the errors partly cancel and the estimate is typically much better
than $L_n$ or $R_n$ at the same $n$. For $\int_1^2 (1/x)\,\d x$ with $n = 5$, the
midpoints are $1.1, 1.3, 1.5, 1.7, 1.9$ and

$$
\int_1^2 \frac{1}{x}\,\d x \approx \frac{1}{5}\parens{\frac{1}{1.1} + \frac{1}{1.3} + \frac{1}{1.5} + \frac{1}{1.7} + \frac{1}{1.9}} \approx 0.6919.
$$

Estimating the same integral $\int_0^3 (x^3 - 6x)\,\d x$ discussed above with $n = 40$
midpoints gives $M_{40} \approx -6.7563$, already closer to the exact $-6.75$ than
the right-endpoint sum $R_{40} \approx -6.3998$. The
[approximate-integration lesson](/calculus/techniques-of-integration/approximate-and-improper-integrals)
develops the error bounds that make this precise.

[^sumsquares]: Stewart, §4.1 and Appendix E (Sigma Notation), where the identity $\sum_{i=1}^n i^2 = n(n+1)(2n+1)/6$ is proved by induction.
