Calculator · Engineering Mathematics

Numerical Derivative Calculator

Estimate the first derivative of f at a point from function values alone, using a forward, backward or central difference. The step h is either chosen by a documented precision policy or entered by hand.

Problem definition

Operators + − * / ^, parentheses, pi and e, and sin, cos, tan, asin, acos, atan, exp, sqrt, abs, ln, log, log10. Write 2*x, not 2x.

Difference method

Step mode

Automatic step at this point and method: h ≈ 6.055e-6.

Results

Derivative estimate f′(x)0.5403023059
Methodcentral difference
Step h used6.055454e-6
Step sourceautomatic policy
Function evaluations2

Stencil values

  • f(x − h) = f(1) = 0.8415
  • f(x + h) = f(1) = 0.8415

Stencil plot

f(x) = sin(x) near x = 1. The dashed guide has the slope of the computed difference quotient; it is an estimate of the tangent, not the exact tangent.

Assumptions & validity

  • · f is defined and finite at every stencil point; a non-finite value is reported as a failure rather than skipped.
  • · f is smooth enough near x for the stated truncation order: one extra derivative for the one-sided formulas, two for the central formula.
  • · A discontinuity, corner, cusp or pole inside the stencil invalidates the truncation statement entirely, however small h is.
  • · Accuracy is limited from below by cancellation: as h shrinks, the numerator loses significant digits and the estimate eventually gets worse, not better.
  • · No rigorous error bound is reported, because bounding the truncation term requires a derivative this tool does not have.

Technical reference

Forward: f′(x) ≈ [f(x + h) − f(x)] / h, truncation O(h)

Backward: f′(x) ≈ [f(x) − f(x − h)] / h, truncation O(h)

Central: f′(x) ≈ [f(x + h) − f(x − h)] / (2h), truncation O(h²)

Automatic step, one-sided: h = √ε · max(|x|, 1)

Automatic step, central: h = ∛ε · max(|x|, 1)

f(x)
the function being differentiated
x
evaluation point
h
finite-difference step
ε
machine epsilon of double precision, ≈ 2.22 × 10⁻¹⁶

The total error of a difference quotient is the sum of a truncation term that shrinks with h and a roundoff term that grows like ε/h. The automatic policy sits near the minimum of that sum: √ε for the one-sided formulas, ∛ε for the central formula.

Both policies scale by max(|x|, 1), so the step stays meaningful at the origin and at large |x|, where an absolute step would be lost in the representation of x itself.

The central difference is one order more accurate than the one-sided formulas at the same cost of two evaluations, and is the default for that reason. A one-sided formula is the right choice when f is only defined on one side of x.

A manual h is used exactly as entered after validation; it is never adjusted towards the automatic value.

At a discontinuity, corner or singularity the quotient still returns a number, but that number estimates nothing: the Taylor expansion the formula relies on does not exist there.

Very badly scaled functions defeat the policy: if f varies by many orders of magnitude across the stencil, no single step balances truncation against cancellation.

Related tools