Math Applets

Continuous functions are integrable proof

Continuous functions are integrable proof:

Let f:[a,b]Rf : [a,b] \to \mathbb{R} be continuous. Then ff is integrable.


How to use

  • Visualize the proof idea: for every ε>0\varepsilon>0 we construct staircase functions ψ\psi and φ\varphi such that ψfφandI(φ)I(ψ)=ε.\psi \le f \le \varphi \quad\text{and}\quad I(\varphi)-I(\psi)=\varepsilon.
  • The applet shows when the key “mesh-size condition” of the proof is satisfied.
  • Drag the blue points aa and bb to choose the interval [a,b][a,b].
  • Use the slider ε\varepsilon to choose the tolerance.
  • Use the slider nn to choose the number of subintervals in the uniform partition ZZ.
  • The blue curve is the continuous function ff.
  • The partition ZZ is uniform with mesh size Δx=ban.\Delta x=\frac{b-a}{n}.
  • The applet computes ε~=ε2(ba).\tilde\varepsilon=\frac{\varepsilon}{2(b-a)}. The vertical bracket at x=bx=b has height 2ε~2\tilde\varepsilon.
  • The orange staircase is φ\varphi (intended upper bound), defined on each open interval (xi1,xi)(x_{i-1},x_i) by φ(x)=f(xi)+ε~.\varphi(x)=f(x_i)+\tilde\varepsilon.
  • The purple staircase is ψ\psi (intended lower bound), defined on each open interval (xi1,xi)(x_{i-1},x_i) by ψ(x)=f(xi)ε~.\psi(x)=f(x_i)-\tilde\varepsilon.
  • The filled band between them is colored green/red depending on whether the proof’s size condition is satisfied.
  • The proof requires choosing nn so that Δx<δ\Delta x < \delta, where δ\delta comes from uniform continuity (condition (7.2)).
  • In the applet, this is checked via a sufficient bound (using an estimate of supf\sup|f'| for the fixed function ff). Concretely, it computes a number δ\delta and checks whether ban<δ.\frac{b-a}{n} < \delta.
  • If the applet shows the red message “(ba)/nδ(b-a)/n \ge \delta”, then the proof hypothesis is not satisfied.
    • In this red case, ψ\psi and φ\varphi are still drawn, but they are not guaranteed to satisfy ψfφ\psi \le f \le \varphi on every subinterval.
    • That is exactly why you sometimes see the purple staircase above the blue curve, or the orange staircase below it: the construction only becomes a true lower/upper bound after the mesh is fine enough.
  • To make ψfφ\psi\le f\le\varphi hold, you need to reach the green state. You can do that by:
    • increasing nn (smaller Δx\Delta x),
    • shrinking the interval (smaller bab-a),
    • or increasing ε\varepsilon (larger ε~\tilde\varepsilon, hence an easier condition).
  • Once the display turns green, the intended implication of (7.2) is in effect:xxi<δf(x)f(xi)<ε~,|x-x_i|<\delta \Rightarrow |f(x)-f(x_i)|<\tilde\varepsilon, which gives ψ(x)f(x)φ(x)\psi(x)\le f(x)\le\varphi(x) on each (xi1,xi)(x_{i-1},x_i), matching the proof idea.
Loading graph…
  • Hold Shift + scroll to zoom
  • Hold Shift + drag to move
  • Points shaped like <> act as sliders

Description

Link to code.

Reference: Lecture Notes Calculus 1 ( May22,2022 ) Theorem7.5 page 129

This applet is quiet experimental and visualizes the proof that a continuous function f:[a,b]Rf:[a,b]\to\mathbb{R} is Riemann integrable by constructing two staircase functions ψfφ\psi\le f\le\varphi whose integrals differ by at most ε\varepsilon. The function is fixed in the code as const f = (x: number) => 0.5 * Math.sin(x) * x + 2.5;.

A good way to use the applet is the same order as the proof. First fix an interval [a,b][a,b] by dragging the gliders gliderA and gliderB. Then choose an error tolerance ε>0\varepsilon>0 with epsSlider. After selecting the ε>0\varepsilon>0, thge student should decrease the interval or add more n-steps nSlider, to get condition 7.2 ((ba)/n<δ(b-a)/n < \delta) works and therefore the all construction.

The applet computes ε~=ε/(2(ba))\widetilde{\varepsilon}=\varepsilon/(2(b-a)) via const eTilde = eps / (2 * range);. The dashed bracket at x=bx=b has vertical length 2ε~2 \widetilde{\varepsilon} (objects epsBracket and epsBracketLabel), and it is colored green/red together with the construction.

Next choose nn (the number of subintervals) with nSlider. The applet creates the uniform partition Z:a=x0<<xn=bZ: a=x_0<\dots<x_n=b with xk=a+k(ba)/nx_k=a+k(b-a)/n, implemented by uniformPartition(a,b,n), where dx=(b-a)/n is the mesh size, as in the proof.

const uniformPartition = (a: number, b: number, n: number) => {
    const dx = (b - a) / n;
    const cuts = Array.from({ length: n + 1 }, (_, k) => a + k * dx);
    cuts[cuts.length - 1] = b;
    return { cuts, dx };
};

On each interval (xi1,xi)(x_{i-1},x_i) the staircase functions are defined using the right endpoint xix_i: upperH[i] = f(x_i) + eTilde; and lowerH[i] = f(x_i) - eTilde; ( I haven’t included codition 7.3: ψ(xi)=φ(xi)=f(xi)\psi(x_i) = \varphi(x_i) = f(x_i)).

These are drawn as step graphs (upperStep for φ\varphi in orange and lowerStep for ψ\psi in purple). The filled region between them (bandPoly) illustrates the intended inequality ψfφ\psi \le f \le \varphi.

To make the δ\delta-step (7.2) explicit, the code uses a Lipschitz bound derived from f(x)f'(x). Since f(x)=12xsinx+2.5f(x)=\tfrac12 x\sin x + 2.5, we have f(x)=12(sinx+xcosx)f'(x)=\tfrac12(\sin x + x\cos x) and therefore f(x)12(1+x)|f'(x)|\le \tfrac12(1+|x|). Hence on [a,b][a,b] we can take supDf = 0.5 * (1 + max(|a|,|b|)) and define delta = eTilde / supDf.

// δ ensuring (7.2)
const maxAbsX = Math.max(Math.abs(a), Math.abs(b));
const supDf = 0.5 * (1 + maxAbsX);
const delta = eTilde / supDf;
// dx < δ
deltaCopndition = dx < delta;

When dx < δ holds, condition (7.2) guarantees that for all x(xi1,xi)x\in(x_{i-1},x_i) we have f(x)f(xi)<ε~|f(x)-f(x_i)|<\widetilde{\varepsilon}, which implies ψ(x)f(x)φ(x)\psi(x)\le f(x)\le\varphi(x) on each subinterval. The band (and the ε~\widetilde{\varepsilon}-bracket) turns green when this condition is satisfied, and red when it is not guaranteed.