Numerical Derivative Calculator (Finite Differences)

Estimate the derivative from data points with forward, backward and central differences. Enter equally spaced y-values or any x, y pairs.

At least 2 values. Use a point for decimals (1.5), no thousands separators, and separate numbers with spaces or a comma and a space.
Must be greater than 0. The x-values are x₀, x₀ + h, x₀ + 2h, …
Must be one of your x-values. A table for every point is shown below.

Results

Best estimate of the derivative
4
f′(2) by the central difference.
Forward difference (yᵢ₊₁ − yᵢ)/(xᵢ₊₁ − xᵢ)
5
Backward difference (yᵢ − yᵢ₋₁)/(xᵢ − xᵢ₋₁)
3
Central difference (yᵢ₊₁ − yᵢ₋₁)/(xᵢ₊₁ − xᵢ₋₁)
4
Spacing
Equally spaced, h = 1. The central difference is second-order accurate (error shrinks with h²); forward and backward are first order (error shrinks with h).
Differences at every point
x | y | forward | backward | central 0 | 0 | 1 | – | – 1 | 1 | 3 | 1 | 2 2 | 4 | 5 | 3 | 4 3 | 9 | 7 | 5 | 6 4 | 16 | – | 7 | –

How it’s calculated

When you only know a function at a set of points, its derivative can be estimated from the slopes between neighbouring points (finite differences):

forward: f′(xᵢ) ≈ (yᵢ₊₁ − yᵢ) / (xᵢ₊₁ − xᵢ) backward: f′(xᵢ) ≈ (yᵢ − yᵢ₋₁) / (xᵢ − xᵢ₋₁) central: f′(xᵢ) ≈ (yᵢ₊₁ − yᵢ₋₁) / (xᵢ₊₁ − xᵢ₋₁)

With equal spacing h these are (yᵢ₊₁ − yᵢ)/h, (yᵢ − yᵢ₋₁)/h and (yᵢ₊₁ − yᵢ₋₁)/(2h). The central difference is then the average of the forward and backward ones and is usually far more accurate: its error shrinks with h², the others only with h. The formulas above also work for uneven spacing (choose x, y pairs), but then the central difference loses that extra accuracy. At the first point only the forward difference is possible and at the last only the backward one; the calculator uses the best available as the main answer.

Example: y = x² sampled at x = 0, 1, 2, 3, 4 gives 0, 1, 4, 9, 16 (h = 1). At x = 2: forward (9 − 4)/1 = 5, backward (4 − 1)/1 = 3, central (9 − 1)/2 = 4, which is exactly the true derivative 2x = 4. Forward and backward are off by h = 1 in opposite directions.

Frequently asked questions

Which difference should I use?

The central difference whenever there is a point on each side, because it is the most accurate. At the ends of the data use forward (first point) or backward (last point).

Can I use unevenly spaced data?

Yes. Choose “x, y pairs”. Each formula then divides by the actual distance between the points used.

Why is my estimate noisy?

Differences amplify measurement noise: a small error in y divided by a small spacing is a big error in the slope. With noisy data a wider spacing, or fitting a smooth curve first, can give a better derivative.

How do I get a better estimate?

Use more closely spaced data (smaller h), as long as the values are precise enough. For an exact formula, use the polynomial derivative calculator instead.

Embed this calculator

Add this free calculator to your own website. Copy the code below into your page’s HTML:

Need this calculator branded, changed or built around your own prices?See custom business solutions →

Sources

Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.

Added · Last updated · How we check our calculators

Spotted a mistake or missing option? Report a problem· Suggest a calculator