The derivative is a slope and the integral is an area, but both are limits — and the value of seeing them drawn is that the limit stops being an abstraction.
This simulator draws the tangent at a chosen point, computes the derivative both analytically and by central difference, and shades the area under the curve from zero to that point, checked against Simpson’s rule.
The derivative as a local slope
For f(x) = ax² + bx + c the derivative is 2ax + b — the slope of the tangent at any x. At the vertex that slope is zero, which is exactly what "stationary point" means.
The numerical version, (f(x+h) − f(x−h))/2h, approximates the same number. With h = 1e-6 the error is around h², so six or seven digits agree; halving h again does not help, because floating-point subtraction starts to dominate.
The integral as accumulated area
The definite integral from 0 to x₀ is the signed area between the curve and the axis. Signed matters: area below the axis counts negative, which is why an integral can be zero even when the curve is visibly above and below the line.
For a quadratic the antiderivative is (a/3)x³ + (b/2)x² + cx, so the integral has a closed form. Simpson’s rule reproduces it to machine precision here because the rule is exact for polynomials up to cubic.
Analytic versus numerical
Simpson’s advantage is why numerical libraries use it for smooth integrands: doubling the number of points cuts the error by sixteen, against four for the trapezoid rule.
| Method | Formula | Behaviour |
|---|---|---|
| Forward difference | (f(x+h) − f(x))/h | First-order error, biased |
| Central difference | (f(x+h) − f(x−h))/2h | Second-order, symmetric |
| Trapezoid | h/2·(f₀ + 2f₁ + … + fₙ) | Second-order, simple |
| Simpson | h/3·(f₀ + 4f₁ + 2f₂ + …) | Fourth-order, exact for cubics |
What the picture does not show
The tangent is drawn over a short window, so it looks like it touches the curve along a stretch. It touches at exactly one point; the visual coincidence is a consequence of curvature being small at that scale.
The shaded area is likewise an approximation of the limit, computed with 200 subintervals. For a polynomial that is exact up to rounding, but for a function with a sharp feature the same visual would be misleading.
Frequently asked questions
Why do the analytic and numerical derivatives differ in the last digits?
Because the numerical version subtracts two nearly equal numbers and divides by a tiny h, which amplifies floating-point error. Agreement to six or seven decimals is the expected result, not a bug.
What does a negative integral mean?
That the area below the axis outweighs the area above it over that interval. The integral is a signed sum, not a geometric area; take absolute values if you want the total area.
Why is the tangent flat at some points?
Because the derivative is zero there — a stationary point. For a quadratic that happens only at the vertex, where the curve turns from falling to rising.
Can this handle other functions?
The page is limited to quadratics so that the closed-form answers stay simple and checkable. The numerical methods it shows apply to any smooth function, which is the point of comparing them.