Derivative Graph & Finite Difference Calculator

Check an exact derivative at a chosen x, then shrink the sample step. See when a finite difference improves and when small changes disappear in floating-point arithmetic.

Numerical calculus

Compare analytic and finite-difference slopes

Polynomial and probe

Polynomial coefficients

The graph spans one radius on either side of the probe. The audit tests 13 steps, halving h each time.

Slope and error audit

Exact analytic slope

f′(2) = 10

f′(x) = 3x^2 − 2

Step 1 of 13 · h = 0.5

Exact quotient
41/4
Binary64 quotient
10.25
Exact truncation
1/4
Rounded coordinates and samples
0
Subtraction rounding
0
Step representation and division
0
Total arithmetic effect
0
Total error from analytic slope
1/4

Lowest tested binary64 error at step 13 · h = 0.0001220703

Error by step

Nonzero magnitudes on a log scale from 10^-8 to 10^0.

Error by stepThe purple dashed trace shows exact truncation error magnitude. The green trace shows binary64 total error magnitude. Each step halves h.Larger hSmaller h
Binary64 totalExact truncation
Step ledger and CSV
Centered difference steps
StephExact slopeBinary64Total error
10.541/410.251/4
20.25161/1610.06251/16
30.125641/6410.015631/64
40.06252561/25610.003911/256
50.0312510241/102410.000981/1024
60.01562540961/409610.000241/4096
70.0078125163841/1638410.000061/16384
80.00390625655361/6553610.000021/65536
90.0019531252621441/262144101/262144
100.000976562510485761/1048576101/1048576
110.000488281341943041/4194304101/4194304
120.0002441406167772161/16777216101/16777216
130.0001220703671088641/67108864101/67108864

How to use this calculator

  1. Enter the constant through fourth-power coefficients, a probe x, an initial step h and the graph radius.
  2. Compare the analytic slope with a forward, backward or centered difference. Move the step slider to halve h.
  3. Read the signed errors and check whether the sample coordinates or function values have rounded together.
  4. Switch to the derivative graph to locate the probe. Open the step ledger to inspect or export the full tested sequence.

The Formula

The mathematical logic powering this calculation is:

Differentiate Σ cⱼxʲ term by term. The exact forward quotient uses [f(x+h) − f(x)]/h, the backward quotient [f(x) − f(x−h)]/h, and the centered quotient [f(x+h) − f(x−h)]/(2h). Truncation is the exact quotient minus the analytic derivative.

The parallel binary64 path evaluates the polynomial with Horner multiplication and addition at the floating-point sample coordinates. It subtracts the two resulting values and divides by the represented step. Each finite binary64 result is decoded as its exact binary fraction to measure its signed error against the rational result.

The sample effect uses the exact difference of the rounded sample values divided by the authored denominator, less the exact quotient. Subtraction rounding measures the change between that exact difference and the actual binary64 subtraction, in quotient units. Step and division effect measures the remaining change to the actual quotient. These contributions add to the arithmetic effect. Add truncation to obtain total error.

The 13 steps are h₀ through h₀/4,096. The best tested binary64 step minimizes absolute total error and keeps the first step if tied. The error chart uses log₁₀ for nonzero magnitudes and a separate zero lane when needed. The derivative graph samples 65 points centered at the probe.

Use signed coefficients, a probe and a positive graph radius within magnitude 1,000,000, with up to six decimal places. The radius is at least 0.000001. The initial h is 0.000000000000001 to 1,000,000, with up to 15 decimal places. The worksheet covers polynomials through degree four.

Worked Example

If you input:

  • Polynomial coefficients: f(x) = x³ − 2x
  • Probe x: 2
  • Initial step h: 0.5
  • Graph radius: 2

Result:

The derivative is 3x² − 2, giving slope 10 at x = 2. At h = 0.5 the forward quotient is 53/4, backward is 29/4 and centered is 41/4. The centered truncation error is 1/4 and binary64 adds no rounding error for this step.

Frequently Asked Questions

Why can a smaller step increase error?

A smaller step can reduce the exact formula error while leaving less change between rounded function values. Dividing by the smaller step can amplify the effect of rounding.

What happens when two sample values round together?

Their binary64 subtraction gives zero. The exact quotient can still be nonzero. The sample effect identifies loss already present in the rounded values, even if the subtraction instruction itself adds no rounding.

Why is centered truncation often smaller?

Symmetric samples cancel the even powers of h in the numerator. For a cubic, this leaves a quotient error proportional to h squared. For a quadratic, the exact centered quotient has zero truncation.

Can the total error be smaller than the truncation alone?

Yes. The rounding contribution is signed. It can cancel part of the truncation error, so the graph shows magnitudes while the ledger retains the signs.

Is the suggested step best for every input?

It is the lowest-error step from this worksheet’s 13 tested values at the current x and method. A different polynomial, location or evaluation algorithm can change that comparison.

Why do exact and binary64 scores disagree?

The exact path retains decimal values as fractions. The binary64 path rounds the inputs, function evaluations and arithmetic operations, so it can reveal differences hidden by the displayed number of digits.

Similar Calculators