The Definite Integral
The limit of Riemann sums appeared twice in the previous lesson, once for area and once for distance. It deserves a name and a symbol of its own: the definite integral. This lesson gives the precise definition (allowing negative values and unequal strips), says which functions are integrable, and derives the properties used in every later computation. For a first look see The Definite Integral.
Definition
A partition of is a list , with widths and norm . Choose sample points in .
Definition. is integrable on if there is a number such that for every there is a with
for every partition with and every choice of sample points. Then .
The is an elongated S for "sum", is the integrand, are the limits of integration, and names the variable. The variable is a dummy: .
Theorem. If is continuous on , or bounded with only finitely many jump discontinuities, then is integrable on .
Not every bounded function is integrable. The function that is 1 on rationals and 0 on irrationals has every upper sum equal to and every lower sum equal to 0, so the Riemann sums have no single limit. (Lebesgue's theory, used in probability, does integrate it, to 0.)
Net signed area
When takes negative values, the terms below the axis are negative. The integral is the net area: area above the axis minus area below.
import numpy as np
import sympy as sp
x = sp.symbols('x')
f = x**3 - 4*x
print("∫_{-1}^{3} (x^3 - 4x) dx =", sp.integrate(f, (x, -1, 3)))
print("total (unsigned) area =", sp.integrate(sp.Abs(f), (x, -1, 3)))
# Riemann sums with random partitions and random sample points converge to the same value
rng = np.random.default_rng(3)
g = sp.lambdify(x, f)
for n in (10, 100, 10_000):
cuts = np.sort(np.concatenate(([-1.0, 3.0], rng.uniform(-1, 3, n - 1))))
widths = np.diff(cuts)
tags = cuts[:-1] + rng.uniform(0, 1, n) * widths
print(f"n = {n:5}: norm = {widths.max():.4f} sum = {float(np.sum(g(tags) * widths)):.5f}")∫_{-1}^{3} (x^3 - 4x) dx = 4
total (unsigned) area = 12
n = 10: norm = 0.7949 sum = 5.44637
n = 100: norm = 0.2266 sum = 4.14740
n = 10000: norm = 0.0042 sum = 4.00023
The net value is 4: the part of where the cubic is negative () cancels part of the positive area. The random sums approach it as the norm shrinks, exactly as the definition demands.
Evaluating from the definition
With equal widths and right endpoints, and :
For : , ,
Positive area on and negative area on cancel exactly. In practice we rarely use the definition: the Fundamental Theorem makes this a one-line computation.
Properties
For integrable and a constant :
| Property | Statement |
|---|---|
| reversed limits | , and |
| constant | |
| linearity | |
| additivity | (any order of ) |
| positivity | on |
| comparison | |
| bounds | |
| triangle inequality | (for ) |
Each follows from the same fact about Riemann sums, then passing to the limit. Linearity, for instance: .
The bounds property estimates integrals you cannot compute. On , is decreasing from 1 to , so
import math
from scipy.integrate import quad
value, _ = quad(lambda x: math.exp(-x * x), 0, 1)
print(f"lower bound 1/e = {1 / math.e:.4f}")
print(f"quad value = {value:.4f}")
print(f"upper bound 1 = 1.0000")lower bound 1/e = 0.3679
quad value = 0.7468
upper bound 1 = 1.0000
In software
- Integration is a reduction. is a weighted sum, so integrals parallelise like
sum(): GPU kernels, MapReduce jobs and NumPy all compute them as reductions. Additivity is what lets you split the interval across workers. - Signed versus unsigned area. Integrating a signal (audio, accelerometer) gives net area, where positive and negative parts cancel; energy-type quantities integrate or . Mixing these up is a common bug.
- Lebesgue in ML. Probability theory, expectations and loss functions are defined with Lebesgue integrals, but for every continuous density you will meet, they agree with the Riemann integral defined here.
Exercises
Exercise 1: Net versus total area
Compute and the total area between and the axis on .
Answer
Net 0, total 4.
Solution
By symmetry the areas on and are equal with opposite sign. Each is , so the total area is 4.
Exercise 2: Using properties
Given and , find and .
Answer
; .
Solution
Exercise 3: From the definition
Use right-endpoint sums to compute .
Answer
Solution
import sympy as sp
i, n = sp.symbols('i n', positive=True, integer=True)
Rn = sp.summation((3 - 2*i/n) * 2/n, (i, 1, n))
print(sp.simplify(Rn), sp.limit(Rn, n, sp.oo))4 - 2/n 4
Exercise 4: Bounding an integral
Show that .
Answer
On , .
Solution
is increasing on , from to . The bounds property gives . (The true value is about 3.24.)
Test yourself
What is in terms of ?
- 6
- 0
- It cannot be determined
- −6
Which function is NOT Riemann integrable on ?
- 1 on rationals, 0 on irrationals
- a step function with three jumps
- for with
If , which must be true?
- The areas above and below the axis are equal
- on
- is odd