How this calculation works
Arbitrary-node finite difference weights turn samples on an irregular grid into a derivative approximation at a selected coordinate. This calculator solves the scaled polynomial moment equations and returns one weight per node, together with the residual of those equations. It derives the stencil without requiring a particular function or a uniform grid.
Σ_j w_j(x_j−t)^k = k! if k=d, and 0 otherwise, for k=0,…,n−1.A worked example
Nodes −1,0,1 at target zero and derivative order one give weights −1/2,0,1/2. Applying them to x² gives zero, matching its derivative at zero. Applying them to x³ gives one although the true derivative there is zero: exactness stops at the interpolation degree, which is two for three nodes.
Good to know
Floating-point decimal nodes, 2–12 distinct coordinates, derivative order below the node count. A numerically singular stencil or large moment residual is rejected. Coordinates are bounded by ±1,000,000. No rigorous truncation-error or measurement-noise bound is inferred from the residual.
Reference: SymPy — finite difference weights (opens in a new tab) ↗
The target determines the local coordinates
The node list is a collection of physical coordinates, not sample indices. Subtracting the target before raising powers gives the Taylor moments around the requested derivative location. A target outside the node interval is allowed, but it creates an extrapolating stencil whose coefficients may strongly amplify perturbations in the sample data.
The implementation divides these offsets by their largest magnitude before solving. This makes the moment system less sensitive to the overall coordinate scale. Afterwards each weight is divided by that scale raised to the derivative order. Changing metres to millimetres must therefore change derivative weights, even though the normalized stencil geometry stays the same.
The Central first derivative from samples calculator covers a related task. This page focuses on finite difference weights calculator for arbitrary nodes with the method limits and worked example described below.
Polynomial exactness is an algebraic test
For every polynomial degree below the number of nodes, weighted samples reproduce the selected derivative in exact arithmetic. The returned scaled residual measures how closely the floating-point solution satisfies those moment equations. It is useful for detecting a failed linear solve, but it cannot see higher derivatives of an unknown function between the nodes.
Closely spaced nodes relative to the stencil width can make the interpolation problem ill-conditioned. Distinct text entries are not automatically numerically well separated. A small solve residual may coexist with large coefficients and large sensitivity. Inspect the weights before applying the stencil to measurements, especially for high derivative orders or one-sided configurations.
Use the weights with consistent sample ordering
Multiply each returned weight by the function value measured at the node on the same row, then add the products. Reordering nodes is harmless only when the sample values are reordered with them. The table deliberately preserves input order so the stencil can be transferred directly to an existing irregular-grid calculation.
Order zero produces interpolation weights rather than a derivative. For a target equal to a node, those weights should select that node up to roundoff. This provides a separate endpoint check. The related central-difference calculator accepts sample values on a fixed stencil; this page instead derives the coefficients for the geometry you supply.
A few questions, answered
Does a small moment residual mean the derivative is accurate?
No. It verifies the stencil equations, while truncation error and sample noise depend on additional information.
Can I use a target outside the nodes?
Yes, but that is extrapolation and may amplify data errors considerably.