›Derivative & Tangent Line Visualizer Back
Mathematics

Derivative & Tangent Line Visualizer

Choose a function and watch the point of tangency move: the slope of the tangent (derivative), the second derivative and the concavity update in real time. Build calculus intuition by experiencing "the derivative as a limit" dynamically.

Function & Settings

The point of tangency P moves automatically along the curve and the tangent (red) rotates. The green secant passes through P and P+h and coincides with the tangent as h approaches 0: this is "the derivative as a limit".

—
—

While paused the animation stands still. Press the play button to resume the automatic animation.

Results
—
Point x
—
f(x)
—
f'(x) (slope)
—
h (secant step)
Graph (blue: f(x) / orange: f'(x) / red: tangent / green: secant)
The red dot is the point of tangency P and the green dot is P+h. The green secant (f(x+h)−f(x))/h coincides with the red tangent as h→0, and its slope equals the value of the derivative f'(x) (orange).
Theory & Key Formulas
$$f'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}$$ The difference quotient $\frac{f(x+h)-f(x)}{h}$ is the "average rate of change"; its limit as $h \to 0$ is the "instantaneous rate of change = derivative"

Equation of the tangent

Tangent at the point $(a,\, f(a))$: $y = f'(a)(x - a) + f(a)$

Second derivative and concavity

$f''(x) \gt 0$: convex (U-shaped, concave up)
$f''(x) \lt 0$: concave (∩-shaped, concave down)
Sign change at $f''(x) = 0$: inflection point

Understanding the Derivative Through a Conversation

🙋
I memorised rules like "the derivative of x² is 2x", but what is the derivative actually finding?
🎓
Roughly speaking, "how steep the function is at that point (its slope)". For example, differentiating the speed at which a spring is compressed with respect to time gives the acceleration, and differentiating position with respect to time gives velocity. Engineers use it every day as the tool that expresses "how fast this variable is changing right now".
🙋
When h is large in this tool, a green line (the secant) appears that differs from the tangent. Is that the "average rate of change"?
🎓
Yes, exactly! (f(x+h)-f(x))/h is "the average slope between x and x+h". As h gets smaller that line approaches the tangent, and that is why the derivative is defined as "the limit as h approaches 0". The finite-difference methods used in numerical simulation approximate partial differential equations with exactly this "difference quotient".
🙋
I want to prove that the derivative of sin(x) is cos(x). How should I think about it?
🎓
Go back to the definition: lim[h→0] (sin(x+h)-sin(x))/h = lim[h→0] (2cos(x+h/2)sin(h/2))/h, using the sum-to-product formula. Then apply lim[θ→0] sinθ/θ = 1 (an important limit!) and you get cos(x). Choose sin(x) in this tool and watch the point pass x=0 and x=π/2: you can confirm f'=cos(0)=1 (maximum slope at x=0) and f'=cos(π/2)=0 (zero slope at the peak).
🙋
I don't have an intuitive feel for the relation between the second derivative f''(x) and concavity...
🎓
Think of f''(x) as "the rate of change of the slope". If f''(x)>0 the slope increases as x increases (it keeps getting steeper = a convex U shape). If f''(x)<0 the slope decreases (it levels off towards the top = a concave ∩ shape). Choose eˣ in this tool: since f''=eˣ>0 you can confirm it is convex everywhere.

Frequently Asked Questions

A point where the limit of the difference quotient does not exist. For example, f(x)=|x| is not differentiable at x=0 because the left derivative (−1) and right derivative (+1) disagree (a "corner"). Points where the denominator of a rational function is zero and the jumps of a step function are also non-differentiable.
Analytical differentiation gives the exact expression from the rules, whereas numerical differentiation approximates with a difference quotient using a finite h (such as (f(x+h)-f(x))/h). The h visualisation in this tool is a kind of numerical differentiation. Automatic differentiation (AutoDiff) is a third approach that applies the chain rule on a computation graph; backpropagation in deep learning uses it.
A partial derivative differentiates a multivariable function with respect to one variable while the others are held fixed (∂f/∂x). The total differential accounts for small changes in all variables (df = ∂f/∂x dx + ∂f/∂y dy). The finite element method deals with multivariable partial differential equations, so the concept of the partial derivative is fundamental to it.
A Taylor expansion expresses a function as an infinite series of its derivatives: f(x+h) = f(x) + f'(x)h + f''(x)h²/2! + ... Taylor expansion is used for the error analysis of almost every numerical method, including the finite element method, finite differences and numerical integration.

What Is the Derivative and Tangent Line Visualizer?

The model section captures the derivative of a function \( f(x) \) at an arbitrary point \( a \) visually, without carrying out the limit by hand. The slope of the tangent is defined as the limit of the difference quotient \( \frac{f(a+h)-f(a)}{h} \) as \( h \to 0 \); the point \( a \) moves automatically along the curve and the slope at that instant is drawn as the red tangent. In addition, the second derivative \( f''(a) \) is the rate of change of the tangent slope, and its sign determines the concavity: \( f''(a) > 0 \) indicates a convex region and \( f''(a) < 0 \) a concave one. The coupling of formula and graph makes it intuitive that the derivative is the gradient of the local linear approximation and that the second derivative is an indicator of curvature. The model is a foundation for experiencing the basic concepts of calculus as a dynamic simulation.

$f'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h}$

Real-World Applications

Motion analysis in machinery and vehicles
Differentiating the displacement x(t) of a piston or cam follower with respect to time gives the velocity v=dx/dt, and differentiating again gives the acceleration a=dv/dt. The slope dT/dN of an engine torque curve is the sensitivity to speed changes and is used in transmission control design. The "slope of the tangent = instantaneous rate of change" of this tool leads directly to the concepts of velocity and acceleration.

Electrochemistry and battery analysis
Measuring the open-circuit voltage V of a cell as a function of capacity Q and looking at dV/dQ and its sign changes (concavity) reveals phase changes and the progress of degradation (differential capacity analysis). Practice in reading the slope of the tangent and the sign of the second derivative carries straight over to the analysis of experimental data.

Links to CAE analysis and its place in practice
Sensitivity analysis in CAE often approximates the derivative ∂R/∂p of a response R with respect to a shape or material parameter p by the finite difference (R(p+h)−R(p))/h. The trade-off that a large h gives secant error while a tiny h gives rounding error is exactly the gap between secant and tangent you see in this tool as h changes. Having this feel before a full optimisation saves hesitation when setting step sizes and convergence criteria.

Common Misconceptions and Points to Note

It is tempting to think "a point where the tangent slope is 0 = an extremum", but a zero slope need not be a maximum or minimum (a stationary point such as the origin of x³), so the sign of the second derivative must also be checked. It is also a common misconception that "a tangent can be drawn even at a corner": at a point like the origin of the absolute-value function |x|, where the left and right slopes disagree, the tangent is not unique and the function is not differentiable. Furthermore, at a point like the origin of x^(1/3) where the tangent is vertical, the derivative diverges and is undefined. The eight functions of this tool are all smooth within the displayed range, so these exceptions do not appear, but you can observe how the slope grows sharply at the edge of the domain (x→0) for ln(x).

How to Use

  1. Choose the function f(x) with the selector (eight functions: x², x³−3x, sin x, cos x, eˣ, ln x, x·sin x, e^(−x²)). The plot range switches to suit the function
  2. The point of tangency P (red) sweeps back and forth along the curve automatically, and the step h shrinks periodically from about 1.3 to 0.02. Watching the green secant merge into the red tangent is "the derivative as a limit". Press "Pause" to freeze the display and read the values at that instant
  3. The result cards show the point x, f(x), f'(x) (slope of the tangent) and h; the left panel shows the tangent equation and the concavity verdict (sign of f''; "near an inflection point" when |f''|<0.05). The orange dashed curve is the derivative f'(x), and the height of the orange dot on it equals the slope of the tangent

Worked Example

Choose f(x)=x² and pause at the instant the point passes x=1.5: f'(x)=2x gives f'(1.5)=3 in "f'(x) (slope)", and the tangent equation y = 3.000(x − 1.50) + 2.250 (i.e. y=3x−2.25) appears in the left panel. The slope of the green secant is ((1.5+h)²−1.5²)/h = 3+h, so as the animation shrinks h from 1.3 to 0.02 it approaches the tangent slope 3, from 4.3 to 3.02. Since f''=2>0, the concavity verdict is always "convex".

Practical Notes