DigitHelm
Calculus

Numerical Differentiation Calculator | Forward, Central & Richardson

Approximate the derivative of any function f(x) at a given point using forward difference, backward difference, central difference (O(h²) accurate), and Richardson extrapolation (O(h⁴) accurate). Also computes the second derivative via the central second-difference formula and shows the truncation error for each method.

Instant Results100% FreeAny DeviceNo Sign-up

Use: sin, cos, tan, exp, log, sqrt, abs, pow(a,b), PI, E — and standard operators + - * / ( )

What Is the Numerical Differentiation Calculator | Forward, Central & Richardson?

Numerical differentiation approximates derivatives using only function values at nearby points, without requiring an analytic formula. Forward difference uses f(x) and f(x+h) with O(h) truncation error. Backward difference uses f(x−h) and f(x) — same accuracy. Central difference uses f(x+h) and f(x−h) symmetrically and achieves O(h²) accuracy by canceling the first-order error terms. Richardson extrapolation applies central difference at both h and h/2, then combines them as [4C(h/2)−C(h)]/3 to cancel the h² error, achieving O(h⁴) accuracy with only twice the central-difference cost. The second derivative uses [f(x+h)−2f(x)+f(x−h)]/h², also O(h²).

Formula

f′(x) ≈ [f(x+h)−f(x−h)] / (2h)  |  Richardson: [4·C(h/2)−C(h)] / 3  |  f″(x) ≈ [f(x+h)−2f(x)+f(x−h)] / h²

How to Use

  1. 1

    Enter f(x) using standard math notation: sin(x), cos(x), exp(x), log(x), sqrt(x), x*x, 1/x, etc.

  2. 2

    Set x — the point where you want to evaluate the derivative

  3. 3

    Set h — the step size (typically 0.001 to 0.0001; avoid values smaller than 10⁻¹²)

  4. 4

    Click a preset to load a classic function with a known exact derivative

  5. 5

    Click "Differentiate Numerically" — all four first-derivative methods are shown

  6. 6

    Read the error column (relative to Richardson) to see how each method compares

  7. 7

    The second derivative f″(x) appears in the summary card above the table

Enter f(x) as a math expression, set evaluation point x and step size h, then click Differentiate Numerically.

Example Calculation

f(x) = sin(x) at x = π/4, h = 0.001. Exact f′(π/4) = cos(π/4) ≈ 0.70710678. Forward: 0.70675 (error 5×10⁻⁴). Central: 0.70710 (error 2×10⁻⁷). Richardson: 0.70710678 (error < 10⁻¹²). Richardson is 5,000× more accurate than forward difference using the same function evaluations.

Understanding Numerical Differentiation | Forward, Central & Richardson

Method Comparison

MethodFormulaFunction evalsTruncation errorBest h
Forward diff.[f(x+h)−f(x)] / h2O(h)~10⁻⁵
Backward diff.[f(x)−f(x−h)] / h2O(h)~10⁻⁵
Central diff.[f(x+h)−f(x−h)] / 2h2O(h²)~10⁻⁴
Richardson[4·C(h/2)−C(h)] / 34O(h⁴)~10⁻³
2nd deriv.[f(x+h)−2f(x)+f(x−h)] / h²3O(h²)~10⁻⁴

Exact Derivatives for Verification

f(x)f′(x) exactf″(x) exactExample: f′(1)
sin(x)cos(x)−sin(x)0.54030
cos(x)−sin(x)−cos(x)−0.84147
exp(x)exp(x)exp(x)2.71828
log(x)1/x−1/x²1.00000
2x22.00000
3x²6x3.00000
1/x−1/x²2/x³−1.00000
sqrt(x)1/(2√x)−1/(4x^(3/2))0.50000

The Step-Size Dilemma

  • Truncation error decreases as h → 0: smaller h means the finite difference more closely matches the true derivative.
  • Roundoff error increases as h → 0: f(x+h) − f(x) becomes the difference of two nearly equal numbers, losing significant digits in floating-point arithmetic.
  • Optimal h balances these two effects. For double precision (ε ≈ 10⁻¹⁶): forward diff. optimal h ≈ √ε ≈ 10⁻⁸, central diff. optimal h ≈ ε^(1/3) ≈ 10⁻⁵, Richardson optimal h ≈ ε^(1/5) ≈ 10⁻³.
  • Richardson extrapolation shifts the optimal h to a larger value (~10⁻³) while achieving better accuracy — a practical advantage for most purposes.

Frequently Asked Questions

Why is Richardson extrapolation more accurate?

It applies central difference at two step sizes h and h/2, then combines them as [4·C(h/2) − C(h)] / 3. This algebraically cancels the dominant h² error term, leaving an O(h⁴) remainder — four orders of magnitude smaller per halving of h.

Why not use an infinitely small h?

Very small h causes catastrophic cancellation: f(x+h) − f(x) is the difference of two nearly equal floating-point numbers, losing significant digits. The optimal h balances truncation error (decreases with h) against roundoff error (increases as h → 0).

What functions can I use?

sin, cos, tan, asin, acos, atan, exp, log (natural), log10, log2, sqrt, abs, pow(a,b), ceil, floor, round, and standard operators +, -, *, /, (, ).

When would I use forward instead of central difference?

When you can only evaluate f on one side of x — for example, at a boundary of a domain where x−h is invalid. Central difference is almost always preferred when both sides are accessible.

What is the second derivative formula used here?

The central second-difference: [f(x+h) − 2f(x) + f(x−h)] / h². It has O(h²) accuracy. The second derivative measures the curvature (rate of change of slope) at x.

You Might Also Like

Explore 360+ Free Calculators

From math and science to finance and everyday life — all free, no account needed.