Skip to content

Difference Formulas

The slope of the tangent line at xx can be approximated by the slope of a secant line through two nearby points. Depending on which pair of nearby points we choose, we get three distinct finite difference formulas. All three use a small step size hh: the smaller hh is, the better the approximation (up to a limit imposed by rounding error, covered in a later section).


Forward Difference

The forward difference formula uses the current point xx and the next point x+hx + h:

f′(x)≈f(x+h)−f(x)hf'(x) \approx \frac{f(x+h) - f(x)}{h}

It approximates the tangent slope by looking ahead by a step of size hh. Geometrically, this draws a secant line connecting f(x)f(x) and f(x+h)f(x+h). As hh shrinks, the green secant line rotates downward to match the orange tangent line.

Graph showing forward difference: a secant line drawn between x and x+h compared to the true tangent at x.

Worked Example

Problem: Using forward difference with h=0.1h = 0.1, approximate f′(2)f'(2) for f(x)=x3−4x+1f(x) = x^3 - 4x + 1.

Step 1 — Identify the evaluation points

x=2,x+h=2+0.1=2.1x = 2, \qquad x + h = 2 + 0.1 = 2.1

Step 2 — Evaluate ff at both points

f(2)=(2)3−4(2)+1=8−8+1=1f(2) = (2)^3 - 4(2) + 1 = 8 - 8 + 1 = 1

f(2.1)=(2.1)3−4(2.1)+1=9.261−8.4+1=1.861f(2.1) = (2.1)^3 - 4(2.1) + 1 = 9.261 - 8.4 + 1 = 1.861

Step 3 — Apply the formula

f′(2)≈f(2.1)−f(2)0.1=1.861−10.1=0.8610.1=8.61f'(2) \approx \frac{f(2.1) - f(2)}{0.1} = \frac{1.861 - 1}{0.1} = \frac{0.861}{0.1} = \boxed{8.61}


Backward Difference

The backward difference formula uses the current point xx and the previous point x−hx - h:

f′(x)≈f(x)−f(x−h)hf'(x) \approx \frac{f(x) - f(x-h)}{h}

It approximates the tangent slope by looking behind by a step of size hh. Geometrically, the secant line is drawn between the points f(x−h)f(x-h) and f(x)f(x).

Graph showing backward difference: a secant line drawn between x-h and x compared to the true tangent at x.

Worked Example

Problem: Using backward difference with h=0.1h = 0.1, approximate f′(2)f'(2) for f(x)=x3−4x+1f(x) = x^3 - 4x + 1.

Step 1 — Identify the evaluation points

x=2,x−h=2−0.1=1.9x = 2, \qquad x - h = 2 - 0.1 = 1.9

Step 2 — Evaluate ff at both points

f(2)=1(computed above)f(2) = 1 \quad \text{(computed above)}

f(1.9)=(1.9)3−4(1.9)+1=6.859−7.6+1=0.259f(1.9) = (1.9)^3 - 4(1.9) + 1 = 6.859 - 7.6 + 1 = 0.259

Step 3 — Apply the formula

f′(2)≈f(2)−f(1.9)0.1=1−0.2590.1=0.7410.1=7.41f'(2) \approx \frac{f(2) - f(1.9)}{0.1} = \frac{1 - 0.259}{0.1} = \frac{0.741}{0.1} = \boxed{7.41}


Central Difference

The central difference formula uses one point ahead of xx and one point behind xx:

f′(x)≈f(x+h)−f(x−h)2hf'(x) \approx \frac{f(x+h) - f(x-h)}{2h}

Because it is symmetric around xx, the secant line spans from f(x−h)f(x-h) all the way to f(x+h)f(x+h). Visually, this resulting green secant line runs nearly parallel to the true orange tangent line, bypassing the localized curvature at xx.

Graph showing central difference: a secant line drawn between x-h and x+h compared to the true tangent at x.

This is why the first-order errors from both sides partially cancel each other, making central difference significantly more accurate than forward or backward difference for the same step size hh.

Worked Example

Problem: Using central difference with h=0.1h = 0.1, approximate f′(2)f'(2) for f(x)=x3−4x+1f(x) = x^3 - 4x + 1.

Step 1 — Identify the evaluation points

x+h=2.1,x−h=1.9x + h = 2.1, \qquad x - h = 1.9

Step 2 — Evaluate ff at both points

f(2.1)=1.861,f(1.9)=0.259(computed above)f(2.1) = 1.861, \qquad f(1.9) = 0.259 \quad \text{(computed above)}

Step 3 — Apply the formula

f′(2)≈f(2.1)−f(1.9)2(0.1)=1.861−0.2590.2=1.6020.2=8.01f'(2) \approx \frac{f(2.1) - f(1.9)}{2(0.1)} = \frac{1.861 - 0.259}{0.2} = \frac{1.602}{0.2} = \boxed{8.01}


Comparison

The exact derivative at x=2x = 2 is f′(2)=8f'(2) = 8. All three methods use the same function and the same h=0.1h = 0.1:

MethodFormulaResultError
Exactf′(2)=3(2)2−4f'(2) = 3(2)^2 - 48.008.000.000.00
Forward Differencef(x+h)−f(x)h\dfrac{f(x+h)-f(x)}{h}8.618.610.610.61
Backward Differencef(x)−f(x−h)h\dfrac{f(x)-f(x-h)}{h}7.417.410.590.59
Central Differencef(x+h)−f(x−h)2h\dfrac{f(x+h)-f(x-h)}{2h}8.018.010.010.01