← All Labs
MATHS · VISUAL LAB · IDEA 42

Integration & Differentiation — the two are one machine, run backwards

Pick a curve f(x) in the top panel. Slide the cursor across it and two other curves draw themselves: the middle panel plots the slope at each point — the derivative f′ — and the bottom panel plots the signed area collected so far — the integral F. Now the punchline you can watch: the slope of the area curve, at the cursor, is exactly the height of the original curve. Differentiate the accumulator and you get f back. That round trip is the Fundamental Theorem of Calculus.

DRIVE IT

One curve, its slope, its area — moving together.

Drag anywhere on the panels to move the cursor x. Watch the tangent in the top panel, the dot it traces in the derivative panel, and the shaded area it traces in the integral panel — all at the same x.
Canvas · KaTeX · LIVE
Drag left/right to sweep the cursor. The tangent line's steepness up top is being copied into the gold curve; the shaded area is being copied into the teal curve.
CURSOR  x1.20
LOWER LIMIT  a (area starts here)0.00
SECANT WIDTH  h (→0 = true derivative)0.001
f(x)  height
f′(x)  slope
F(x)=∫ₐˣ f  area
F′(x)  (slope of area)
check: F′(x) − f(x)
f(x) f′(x) derivative F(x) integral
WALKTHROUGH

Read the three panels top to bottom.

Each is the same x‑axis. The cursor line ties them together.
GUIDE
1
Top — f(x). Your chosen curve. At the cursor a tangent line is drawn; its steepness is the only thing the derivative panel cares about. Flat spots (peaks, troughs) have zero slope.
2
Middle — f′(x). For every x we plot the tangent's slope as a height. Where f climbs, this gold curve is positive; where f falls, negative; it crosses zero exactly under f's peaks and valleys.
3
Bottom — F(x) = ∫ₐˣ f. Sweep the cursor and we shade the area under f from a to x (area below the axis counts as negative). That running total is plotted as the teal curve. Move a and the whole teal curve just shifts up or down — the constant of integration.
4
The link. Turn on slope→height: the tangent to the teal area curve is drawn, and its slope readout matches f(x) from the top panel. Differentiating the accumulator hands you back the original height. Shrink h to 0.001 and the secant becomes the true derivative.
AHA

The area function's slope is the curve.

THE POINT
AHA MOMENT
To find the area under a curve, don't add up a million rectangles — find a function whose slope is that curve, and subtract its values at the two ends. Differentiation and integration aren't two topics that happen to sit in the same course; they are one operation and its exact inverse. The proof is not an algebra ritual — it's the gold curve and the teal curve watching each other, and it's watchable in the panels above.
EXPLANATION

Why the round trip closes.

The two halves of the Fundamental Theorem of Calculus.
THE MATHS

The accumulator. Define the area‑so‑far function — the signed area under f from a fixed start a out to x. This is the teal curve.

Part 1 — differentiate it and f returns. Nudge x by a tiny h. The extra area is a thin sliver of width h and height ≈ f(x), so . Divide by h and let h→0: . The slope of the area curve at x is the height of the original curve at x. That is exactly the slope→height link you toggled on.

Part 2 — evaluate an integral without adding rectangles. If is any antiderivative (F′ = f), then the definite integral is just a subtraction at the endpoints: . Changing the lower limit a only adds a constant — which is why dragging a slides the whole teal curve vertically without changing its shape.

The secant slider. The middle panel really computes a symmetric secant slope . At h=1.5 you see a crude chord; at h=0.001 it is the derivative to five digits. The "check" readout F′(x) − f(x) stays within a whisker of zero — the theorem, measured live.

FUNDAMENTAL THEOREM OF CALCULUS — the whole thing
Part 1 (top): the accumulator's derivative is the integrand. Part 2 (bottom): a definite integral is an endpoint difference of any antiderivative. Read together: d/dx and ∫dx undo each other.
WATCH FOR IT IN THE PANELS
Zeros ↔ extrema: the gold f′ crosses zero right under every peak/valley of f.
Sign ↔ monotonicity: gold above axis ⇒ teal F rising; gold below ⇒ F falling.
Area sign: where f dips below the axis the fill turns pink and F decreases.
Constant of integration: dragging a is the +C freedom — same shape, shifted height.
RESEARCH NOTE

What is computed live, and how it was checked.

METHOD

Nothing here is a pre‑baked plot. Each frame, for a dense grid of x, the applet evaluates f directly, the derivative as a centred secant , and the integral as a cumulative trapezoidal sum of f from the lower limit a. The three curves are therefore genuinely the same underlying array read three ways: values, finite‑difference slopes, and running sums.

The invariant F′(x) ≈ f(x) is measured on screen (the "check" readout) and was also verified offline across all presets and many x: with h=1e‑3 the maximum of |F′(x) − f(x)| stays below 1e‑2 for smooth presets, shrinking with h as expected for a centred difference. Trapezoidal F reproduces the closed‑form antiderivatives (e.g. ∫sin = 1−cos from 0, ∫x² = x³/3) to grid accuracy. Endpoints of F are pinned so F(a)=0. "Draw your own f" feeds hand‑drawn samples through the same three pipelines, so the theorem holds for arbitrary curves, not just the presets.

Part of the repo's visual‑maths lab. Siblings: Taylor series (#3, local polynomial approximation), Arc length as a rolling odometer (#6, integration as accumulated travel), Vector fields & ODE flow (#5), and Monte Carlo estimating π (#17, integration by randomness). Single file, no build step, Canvas 2D + KaTeX.