How to Animate the Derivative | QuantumSketch
Animate the derivative by drawing a secant line on a curve and shrinking the gap h toward zero until it becomes the tangent. Here's the visual and the prompt.
Animate the derivative by drawing a secant line through two points on a curve, then shrinking the gap h toward zero until the secant becomes the tangent. The slope of that final tangent is the derivative ā this is the limit definition made visible.
The visual, beat by beat
- Plot the curve. Draw
f(x) = x²onAxes. Mark point P at x = 1. - Draw the secant. Add a second point Q at x = 1 + h, connect PāQ.
- Shrink h. Animate h: 1 ā 0.5 ā 0.1 ā 0.01. Q slides toward P; the secant rotates.
- Snap to tangent. At the limit, the secant is the tangent. Show its slope.
- Reveal f'(x) = 2x ā at x = 1, slope = 2.
This shows why the derivative equals the limit of the difference quotient, not just the formula.
The math on screen
As h ā 0, the average rate of change (secant slope) becomes the instantaneous rate (tangent slope).
How Manim builds it
| Element | Manim object |
|---|---|
| Axes + curve | Axes, axes.plot |
| Moving point | Dot + ValueTracker |
| Secant line | always_redraw(Line) |
| Slope label | DecimalNumber |
A ValueTracker on h drives everything; always_redraw keeps the secant attached as h changes. Want the mechanics? See Mobjects, Scenes & Animations Explained.
The one-line prompt
"Show the derivative of f(x) = x² as a secant through P=(1,1) and a point h away, shrinking h to 0 until it's the tangent; display the slope updating to 2."
Animate it now
ā Paste that into quantumsketch.app for a narrated render. Next: Animate Riemann Sums and Visualize Gradient Descent.
Written by Shihab Shahriar Antor Ā· Shahriar Labs
FAQ
Q.What's the clearest way to show what a derivative is?
The clearest visual is the secant-to-tangent animation. Plot a curve like f(x) = x², mark a point P, and draw a secant line through P and a nearby point Q a distance h away. As you animate h shrinking toward zero, Q slides toward P and the secant rotates until it becomes the tangent line at P. The slope of that final line is the derivative f'(x). This directly shows the limit definition ā the derivative is the slope the secant approaches as h goes to 0 ā far better than a static formula.
Q.How do I animate the derivative without coding it myself?
Describe it as a prompt to an AI animation tool: 'Show the derivative of f(x) = x² as a secant line through P and a point h away, then shrink h to zero so it becomes the tangent; display the slope updating.' QuantumSketch turns that into a narrated Manim animation. Under the hood it uses Manim's Axes, a plotted function, a secant Line, and a Transform driven by a ValueTracker on h ā but you don't write any of it. You just refine the prompt until the pacing feels right.