Numerical Derivative Calculator

This calculator estimates the slope of a function at a chosen point without symbolic differentiation. Enter a function of x, the point of interest, and a small step size, and it returns the first and second derivatives using the central difference method. The central difference is second-order accurate, meaning its error falls with the square of the step size, so it is far more accurate than a one-sided forward difference for the same step. The expression parser handles standard arithmetic, powers, and the common trigonometric, exponential and logarithmic functions.

0.00
0.00
0.00
0.00

Central difference formula

f'(x) = (f(x + h) - f(x - h)) / (2h)
f''(x) = (f(x + h) - 2 f(x) + f(x - h)) / h^2
Tangent slope at x equals f'(x)

Use x as the variable. Supported: + - * / ^, sin, cos, tan, exp, ln, log, sqrt, abs, pi, e.

Numerical differentiation context

  • The central difference is second-order accurate, so error scales with h squared.
  • A step near 1e-5 balances truncation error against floating-point round-off.
  • Too small a step subtracts nearly equal numbers and loses precision.
  • The estimate is unreliable near corners or discontinuities where the derivative is undefined.
  • The first derivative equals the slope of the tangent line at the point.

Numerical derivative: frequently asked questions

What method does this derivative calculator use?

It uses the central difference approximation. The first derivative at x is (f(x plus h) minus f(x minus h)) divided by 2h. The second derivative is (f(x plus h) minus 2 f(x) plus f(x minus h)) divided by h squared. The central difference is second-order accurate, so the error shrinks with the square of the step size.

What functions can I enter?

Use x as the variable and standard notation: plus, minus, times as star, divide, and power as caret. Supported functions include sin, cos, tan, exp, ln, log (base 10), sqrt, abs and the inverse and hyperbolic trig functions. Constants pi and e are recognised.

How should I choose the step size h?

A step around 1e-5 works well for most smooth functions. Too large a step adds truncation error; too small a step causes floating-point round-off because you subtract nearly equal numbers. If the result looks unstable, try adjusting h up or down by a factor of ten.

Why is the central difference better than the forward difference?

The forward difference, (f(x plus h) minus f(x)) divided by h, has error proportional to h. The central difference cancels the leading error term, leaving error proportional to h squared, so for the same step size it is far more accurate. That is why this calculator uses the central form.

Does this give an exact derivative?

No. It is a numerical approximation, not symbolic differentiation. For smooth functions it is usually accurate to many digits, but near points where the function is not differentiable, such as a sharp corner, the estimate can be unreliable.

Official sources

  • NIST Digital Library of Mathematical Functions: Numerical Methods, differentiation.
  • U.S. National Institute of Standards and Technology: NIST home, mathematical references.

Reviewed by the CalculatorHub team, edited by James Graham, 17 June 2026. See our methodology.