Home▸Mathematics▸Derivative Visualizer 2D: Numeric vs Analytic Slope (2D)

Derivative Visualizer 2D: Numeric vs Analytic Slope (2D)

A Canvas2D companion to the derivative visualizer: drag x0, shrink h and watch the secant become the tangent, while a live panel runs a central-difference numerical derivative against the exact analytic one, tracks the error between them, and estimates concavity via f''(x0).

Mathematics2DEasy60 FPS⇄ 3D version
2d-derivative-visualizer ↗ Open standalone

This 2D companion trades the WebGL-rendered original for a plain Canvas2D view built to make the numbers, not the scene, the focus. It keeps the same core idea — drag x0, shrink h, watch the secant collapse onto the tangent — but adds a second derivative estimate computed independently by central difference, so you can watch a numerical method converge on the exact calculus answer and see where floating-point error starts to dominate if h gets too small. A custom quadratic mode (adjustable a, b, c) lets you build your own function instead of only picking from the presets, and a live concavity readout (f″(x0), estimated the same way) flags convex, concave and near-inflection points as you drag.

⚙ Under the hood

Canvas2D derivative lab: central-difference numerical derivative run alongside the exact analytic one, secant-to-tangent animation, adjustable zoom and shrink speed, and a custom ax²+bx+c mode.

derivativetangent linesecant linelimit definitionnumerical differentiationcalculus

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

Frequently Asked Questions

Why do the numeric and analytic derivatives sometimes disagree?

The numeric value uses a central-difference approximation [f(x0+ε) − f(x0−ε)] / (2ε) with a small fixed probe ε, which has O(ε²) truncation error. Push ε (or h) below roughly 1e-4 in double precision and floating-point cancellation — subtracting two nearly equal numbers — starts to dominate, so the error can grow again instead of shrinking further.

What does the f″(x0) concavity readout mean?

It is the second derivative estimated the same way as the first — a second central difference. Positive f″ means the curve bends upward (convex) at x0, negative means it bends downward (concave), and a value near zero flags a possible inflection point where concavity switches sign.

How is this different from the 3D version?

The 3D version renders the same secant/tangent geometry through WebGL. This 2D version renders with plain Canvas2D and adds a numeric-vs-analytic derivative comparison, a concavity readout, an adjustable custom quadratic function, and independent zoom and animation-speed controls not present in the original.

What did you find?

Add reproduction steps (optional)