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):
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
- Python Numerical Methods, §20.2 Finite Difference Approximating Derivatives — UC Berkeley
- NIST Digital Library of Mathematical Functions, §3.4 Differentiation (three-point formula: at t = 0 it is the central difference) — NIST
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