Foundations to Frontier
Tests
A. Mathematical Foundations › A3 Calculus and Analysis › Single-variable calculus

Integrals: the Riemann Integral and the Fundamental Theorem of Calculus

Integration adds up infinitely many tiny pieces. It gives areas, distances from speeds, probabilities from densities, and averages. The fundamental theorem says integration and differentiation undo each other, turning hard sums into simple subtraction.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Adding up tiny pieces

If you drive at a steady 60 km/h for 2 hours, you travel 120 km: speed × time. But what if your speed keeps changing? Chop the trip into many tiny moments. In each one the speed is nearly constant, so add up speed × (tiny time). With more and thinner slices, the total gets exact. That’s an integral.

On a graph of speed against time, each slice is a thin rectangle, so the distance is the area under the curve.

Area by strips: Riemann sums
midpoint sum = 2.648148 · exact ∫ = 2.666667 · error 1.85e-2
Exact: 8/3. Double n and watch the error: left/right shrink about 2×, midpoint and trapezoid about 4×. Orange strips lie below the axis and subtract.
Why engineers care

A spacecraft’s navigation computer can’t see where it is. It knows how hard its thrusters pushed, moment by moment. Adding those pushes up (integrating) gives its speed, and adding the speeds up gives its position. Tiny errors in that sum also add up, which is why spacecraft also take star sightings.

📝 Quick check (Level 0)
0/3 answered
  1. 1. 60 km/h for 2 hours covers…
  2. 2. On a speed–time graph, the distance is the…
  3. 3. Using more, thinner strips makes the area estimate…

Level 1: Beginner

★★☆☆☆ Basic⏱ 15 minSecondary-school mathematics: arithmetic and elementary algebra.

Riemann sums

Split [a,b][a,b] into nn strips of width h=(b−a)/nh = (b-a)/n, and add the strip areas:

∫abf(x) dx=lim⁡n→∞∑i=1nf(xi∗) h\int_a^bf(x)\,dx = \lim_{n\to\infty}\sum_{i=1}^nf(x_i^*)\,h

The fundamental theorem of calculus (FTC)

If F′=fF' = f (FF is an antiderivative), then

∫abf(x) dx=F(b)−F(a)\int_a^bf(x)\,dx = F(b) - F(a)

An infinite sum becomes one subtraction. With ∫xn dx=xn+1n+1+C\int x^n\,dx = \frac{x^{n+1}}{n+1} + C:

  • ∫01x2dx=13\int_0^1x^2dx = \frac13
  • ∫132x dx=9−1=8\int_1^32x\,dx = 9 - 1 = 8
  • ∫0πsin⁡x dx=[−cos⁡x]0π=2\int_0^\pi\sin x\,dx = [-\cos x]_0^\pi = 2
📝 Quick check (Level 1)
0/3 answered
  1. 1. ∫₀¹ x² dx = ?
  2. 2. ∫₀² 3 dx = ?
  3. 3. ∫₀² x³ dx = ?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 45 minUndergraduate students and practising engineers.

Numerical integration rules

Rule Formula on one strip Error (total)
left/right h f(xi)h\,f(x_i) O(h)O(h)
midpoint h f(xi+h/2)h\,f(x_i + h/2) O(h2)O(h^2)
trapezoid h2(f(xi)+f(xi+1))\frac h2(f(x_i) + f(x_{i+1})) O(h2)O(h^2)
Simpson h3(f0+4f1+f2)\frac h3(f_0 + 4f_1 + f_2) on pairs of strips O(h4)O(h^4), exact for cubics
🐍 Exercise 1: integration rules and their orders
Implement left, right, midpoint, trapezoid and Simpson. On ∫₀^π sin x dx = 2, halve h and confirm the error ratios 4 (mid, trap) and 16 (Simpson). Check the left rule's ratio of 2 on x².

What integrals mean

Quantity Integral
distance from velocity ∫0Tv(t) dt\int_0^Tv(t)\,dt (robot odometry)
average value fˉ=1b−a∫abf\bar f = \frac1{b-a}\int_a^bf, e.g. the RMS of a voltage
probability P(a≤X≤b)=∫abp(x) dxP(a\le X\le b) = \int_a^bp(x)\,dx, with ∫p=1\int p = 1 (A4)
expected value E[X]=∫x p(x) dx\mathbb E[X] = \int x\,p(x)\,dx
work ∫F(x) dx\int F(x)\,dx

Area below the axis counts as negative: ∫−11x3dx=0\int_{-1}^1x^3dx = 0.

FTC, part 1

ddx∫axf(t) dt=f(x)\frac{d}{dx}\int_a^xf(t)\,dt = f(x)

The running integral is an antiderivative, even when no formula exists. For example, ∫0xe−t2dt\int_0^xe^{-t^2}dt (the error function) has derivative e−x2e^{-x^2}.

📝 Quick check (Level 2)
0/3 answered
  1. 1. The average of sin on [0, π]?
  2. 2. d/dx ∫₀ˣ t² dt at x = 3?
  3. 3. Simpson's rule is exact for polynomials up to degree…

Level 3: Advanced

★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.

The precise definition (Darboux)

For a partition PP, the lower sum L(f,P)L(f,P) uses inf⁡f\inf f on each strip, and the upper sum U(f,P)U(f,P) uses sup⁡f\sup f. ff is Riemann integrable if sup⁡PL=inf⁡PU\sup_PL = \inf_PU, and that common value is the integral.

  • Continuous ⇒ integrable. On [a,b][a,b], ff is uniformly continuous (Heine–Cantor). So for fine partitions, sup⁡−inf⁡<ε\sup - \inf<\varepsilon on every strip, and U−L<ε(b−a)U - L<\varepsilon(b-a).
  • Monotone ⇒ integrable, with U−L=∣f(b)−f(a)∣hU - L = \lvert f(b) - f(a)\rvert h.
  • Not integrable: the Dirichlet function (1 on rationals, 0 on irrationals). Every lower sum is 0 and every upper sum is b−ab - a. The Lebesgue integral handles it (value 0), and it is the foundation of modern probability.

Proof of the FTC

Part 1. Let G(x)=∫axfG(x) = \int_a^xf. Then G(x+h)−G(x)h=1h∫xx+hf=f(ch)\frac{G(x+h) - G(x)}h = \frac1h\int_x^{x+h}f = f(c_h) for some ch∈[x,x+h]c_h\in[x,x+h] (the mean value theorem for integrals, using continuity). As h→0h\to0, ch→xc_h\to x, so G′(x)=f(x)G'(x) = f(x). ∎

Part 2. If F′=fF' = f, then (F−G)′=0(F - G)' = 0, so F−GF - G is constant (by the MVT). Hence F(b)−F(a)=G(b)−G(a)=∫abfF(b) - F(a) = G(b) - G(a) = \int_a^bf. ∎

Exercise 3.1: Why is the trapezoid error O(h²) but the left-rule error only O(h)?

On one strip, the left rule misses the triangle 12f′h2\tfrac12f'h^2. Summed over n=(b−a)/hn = (b-a)/h strips, that is O(h)O(h). The trapezoid uses the chord, so the linear term cancels and the leftover per strip is −112f′′h3-\tfrac1{12}f''h^3, giving O(h2)O(h^2) in total.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Is the Dirichlet function Riemann integrable?
  2. 2. Continuous on [a, b] implies…
  3. 3. The upper sum of f(x) = x on [0, 1] with 4 strips?

Level 4: Expert

★★★★★ Expert⏱ 40 minResearchers: original papers and open problems.

Dead reckoning: integration in robot navigation

An inertial measurement unit (IMU) measures acceleration. Integrating once gives velocity, and integrating twice gives position. A constant accelerometer bias bb grows into a position error of 12bt2\tfrac12bt^2. Noise grows too, as a random walk. That’s why rovers, drones and spacecraft fuse IMUs with GPS, wheel odometry, star trackers or cameras through Kalman filtering (Kalman, 1960; Groves, 2013).

🐍 Exercise 2 (research): IMU dead reckoning drift
Integrate a 100 Hz accelerometer signal twice with the trapezoid rule. Clean data stays accurate to 1 mm, but a 0.01 m/s² bias drifts about ½bt² ≈ 18 m in a minute.

Beyond the basic rules

  • Gaussian quadrature (Gauss, 1814) chooses the nodes as roots of Legendre polynomials (A2.4-1). nn points are exact up to degree 2n−12n - 1 (Practice Code 5). It is used in finite-element codes and in physics simulators’ integrators.
  • Adaptive quadrature (QUADPACK, Piessens et al., 1983; behind scipy.integrate.quad) refines strips only where the error estimate is large.
  • Monte Carlo integration estimates ∫f\int f by averaging ff at random points. Its error is O(1/N)O(1/\sqrt N) in any dimension, which is why it dominates high-dimensional integrals: Bayesian inference, rendering, and expected rewards in reinforcement learning (Metropolis and Ulam, 1949).
  • ODE solvers are integration rules applied to x˙=f(x,t)\dot{\mathbf x} = f(\mathbf x,t). Euler is the left rule, and Heun’s method and RK2 are trapezoid-like. They are the engine of every robot simulator.

References

  1. B. Riemann (1854). “Über die Darstellbarkeit einer Function durch eine trigonometrische Reihe.” (Habilitation thesis; the Riemann integral.)
  2. G. Darboux (1875). “Mémoire sur les fonctions discontinues.” Annales scientifiques de l’ÉNS, 4.
  3. C. F. Gauss (1814). “Methodus nova integralium valores per approximationem inveniendi.”
  4. H. Lebesgue (1902). Intégrale, longueur, aire. Thesis, Paris.
  5. N. Metropolis, S. Ulam (1949). “The Monte Carlo method.” Journal of the American Statistical Association, 44.
  6. R. Piessens, E. de Doncker-Kapenga, C. Überhuber, D. Kahaner (1983). QUADPACK: A Subroutine Package for Automatic Integration. Springer.
  7. P. Groves (2013). Principles of GNSS, Inertial, and Multisensor Integrated Navigation Systems, 2nd ed. Artech House.