Interactive tool

Tangent line explorer

Slide a point along a curve and watch the tangent line and the derivative change with it.

Pick a function and move the point x0x_0 with the slider or by dragging across the graph. The solid line is the tangent at that point. The dashed line is a secant through x0x_0 and a second point x0+hx_0 + h. Make hh small and the two lines become hard to tell apart.

Derivativef′(x) = 2x
−2−112−11234567xy
1.00

You can also drag across the graph

1

Slide toward the middle to shrink h

Point
(1.00, 1.000)
Tangent slope
2.000
Secant slope
3.000
Tangent line
y = 2.000x − 1.000

Things to try

  • Start with x2x^2 at x0=1x_0 = 1. Move hh toward the middle of its slider, first from the right and then from the left. The secant slope comes down to 22 from above and climbs up to 22 from below.
  • Switch to x3−3xx^3 - 3x and find the two places where the tangent line is flat. Check them against f′(x)=3x2−3f'(x) = 3x^2 - 3.
  • With exe^x, compare the height of the point with the tangent slope. They are the same number at every x0x_0.
  • With ln⁡x\ln x, move x0x_0 toward 00. The slope is 1x0\frac{1}{x_0}, so it doubles every time x0x_0 is cut in half.
  • With sin⁡x\sin x, set x0=0x_0 = 0. The tangent there is the line y=xy = x, which is why sin⁡x≈x\sin x \approx x when xx is small.
  • With x\sqrt{x} at x0=2x_0 = 2, compare h=1h = 1 with h=−1h = -1. The curve bends downward, so the secant to the right is flatter than the tangent and the secant to the left is steeper.

What you are seeing

The slope of the secant line is the difference quotient

msec=f(x0+h)−f(x0)h,h≠0.m_{\text{sec}} = \frac{f(x_0 + h) - f(x_0)}{h}, \qquad h \neq 0.

The dotted right angle between the two points shows it as rise over run, with run hh and rise f(x0+h)−f(x0)f(x_0 + h) - f(x_0).

The derivative is the limit of that quotient as hh goes to 00, when the limit exists.

f′(x0)=lim⁡h→0f(x0+h)−f(x0)hf'(x_0) = \lim_{h \to 0} \frac{f(x_0 + h) - f(x_0)}{h}

The tangent line is the line through (x0,f(x0))(x_0, f(x_0)) with slope f′(x0)f'(x_0). The explorer writes it as y=mx+by = mx + b with m=f′(x0)m = f'(x_0) and b=f(x0)−x0f′(x0)b = f(x_0) - x_0 f'(x_0).

For f(x)=x2f(x) = x^2 the quotient simplifies to 2x0+h2x_0 + h, so the secant slope misses the derivative 2x02x_0 by exactly hh. For the other functions the gap is not exactly hh, but it still shrinks to 00 as h→0h \to 0.

The tangent slope comes from the exact derivative, such as ddxsin⁡x=cos⁡x\frac{d}{dx}\sin x = \cos x or ddxx=12x\frac{d}{dx}\sqrt{x} = \frac{1}{2\sqrt{x}}, not from a small hh. For ln⁡x\ln x and x\sqrt{x} the point stays at x0>0x_0 > 0. The slope of x\sqrt{x} grows without bound as x0→0+x_0 \to 0^+, and there is no derivative at 00 itself.

The rules behind these formulas are on the calculus reference sheet, and the videos are on the Calculus course page.