Newton Interpolation Polynomial

← Numerical Methods

Source inspiration: (Mathew 2000-2019).

Description

Given \(n+1\) points \((x_k, y_k)\) with distinct nodes \(x_0, \ldots, x_n\), interpolation asks for the polynomial of degree at most \(n\) that passes through all of them; with \(y_k = f(x_k)\), it approximates \(f\). That polynomial is unique, and Newton interpolation represents it in divided-difference form,

\[ P_n(x)=a_0 + a_1(x-x_0)+a_2(x-x_0)(x-x_1)+\cdots+a_n\prod_{j=0}^{n-1}(x-x_j), \]

where \(a_k=f[x_0,\ldots,x_k]\) are divided differences, built column by column from \(f[x_k] = f(x_k)\):

\[ f[x_i,\ldots,x_{i+j}]=\frac{f[x_{i+1},\ldots,x_{i+j}]-f[x_i,\ldots,x_{i+j-1}]}{x_{i+j}-x_i}. \]

For the same nodes and data, Newton and Lagrange forms produce the same polynomial; they differ only in representation and numerical workflow. Newton’s form suits nodes that arrive one at a time: \(P_n(x) = P_{n-1}(x) + a_n\prod_{j=0}^{n-1}(x-x_j)\), so a new node adds one term and leaves \(a_0, \ldots, a_{n-1}\) unchanged, as the divided-differences case shows frame by frame. The divided-difference table takes \(n(n+1)/2\) divisions, and nested multiplication then evaluates \(P_n(x)\) with \(n\) multiplications.

The nodes must be distinct, since each divided difference divides by \(x_{i+j}-x_i\); building \(P_n\) needs nothing else. The error formula needs more. In general, as Mathews states it, if \(f \in C^{n+1}[a, b]\) and \(x, x_0, \ldots, x_n\) lie in \([a, b]\), then for some \(c\) in \([a, b]\)

\[ f(x) - P_n(x) = \frac{f^{(n+1)}(c)}{(n+1)!}\,(x-x_0)(x-x_1)\cdots(x-x_n). \]

For equally spaced nodes with spacing \(h\) and \(|f^{(n+1)}| \le M_{n+1}\) on \([x_0, x_n]\), Mathews bounds the error on \([x_0, x_n]\) for \(n = 1\) to \(5\), from \(M_2h^2/8\) to \(\frac{10+7\sqrt7}{1215}M_6h^6\), so for a fixed degree the error is \(O(h^{n+1})\). In the divided-differences case, with \(h = 0.2\), the largest error is \(4.97\times10^{-3}\) at degree 1 against the bound \(5.00\times10^{-3}\), and \(1.35\times10^{-6}\) at degree 5 against \(1.50\times10^{-6}\).

Raising the degree on equally spaced nodes does not always help. For \(e^x\) on \([-2, 3]\) the largest error on the node interval falls to \(3.05\times10^{-10}\) at degree 15 (Case 15), but for \(1/(1+10x^2)\) on \([-1, 1]\) it falls to \(0.135\) with 8 nodes and then grows to \(0.485\) with 16 nodes, in oscillations next to the end nodes (Case 08, Runge’s phenomenon). Outside \([x_0, x_n]\) the product \((x-x_0)\cdots(x-x_n)\) grows quickly, so extrapolation is unreliable: for \(\sqrt{x}\) with nodes on \([0, 2]\), the degree-15 interpolant is \(64.5\) at \(x = 2.5\), where \(\sqrt{2.5} \approx 1.58\) (Case 04).

Cases 01–29 below intentionally reuse the same interpolation cases as the Lagrange page, matching the legacy Mathews case ordering; each case heading gives the function and the node interval \([a, b]\). Aitken’s and Neville’s Interpolation evaluate the same polynomial at one point with a similar recursive tableau, Chebyshev Approximation Polynomial clusters the nodes near the ends to tame the oscillations of Case 08, Hermite Polynomial Interpolation also matches derivative values, and Cubic Splines join low-degree pieces instead of raising the degree.

Animations

Cases 01–29 each show the interpolant on 2, 3, 4, 5, 6, 8, 10, 12, 14 and 16 equally spaced nodes (degree 1 to 5, then 7, 9, 11, 13 and 15) for a fixed function and node interval, with nodes at both ends of the interval. The degree in each title is the number of nodes minus one, the most the interpolant can have; its actual degree can be lower. With nodes symmetric about 0, the interpolant of an even \(f\) has only even powers of \(x\) and that of an odd \(f\) only odd powers, so in the even cases (08, 13, 17, 20 and 22) the frame titled degree 1 is a horizontal line and the frame titled degree 15 has degree 14. Mathews’ own animations, of which only those for Cases 01 and 04 survive in the archive, went further, to degree 25 and degree 20 respectively, and drew a yellow bar on the \(x\)-axis, labelled “Tolerance ±0.05”, over an interval on which the interpolant is within \(0.05\) of \(f\); these frames stop at degree 15 and have no such bar.

The shared script draws this same polynomial but evaluates it in the first barycentric (Lagrange) form, not by divided differences. The last case on this page has its own script, which builds the Newton form from divided differences.

Julia source for Cases 01–29

Case 01: \(f(x)=1/(1-x)\), nodes on \([-1.5, 0.9]\)

Newton interpolating polynomials of f(x) = 1/(1−x) through equally spaced nodes on [−1.5, 0.9], degree rising from 1 to 15, in the window [−1.6, 1.5], which includes the pole of f at x = 1; beyond the pole f ≤ −2, below the window.

Case 02: \(f(x)=1/(1+x)\), nodes on \([-0.9, 1.5]\)

Newton interpolating polynomials of f(x) = 1/(1+x) through equally spaced nodes on [−0.9, 1.5], degree rising from 1 to 15, in the window [−1.5, 1.6], which includes the pole of f at x = −1; beyond the pole f ≤ −2, below the window.

Case 03: \(f(x)=1/(1-x)^2\), nodes on \([-1.5, 0.9]\)

Newton interpolating polynomials of f(x) = 1/(1−x)² through equally spaced nodes on [−1.5, 0.9], degree rising from 1 to 15, in the window [−1.6, 1.5], which includes the pole of f at x = 1.

Case 04: \(f(x)=\sqrt{x}\), nodes on \([0, 2]\)

Newton interpolating polynomials of f(x) = √x through equally spaced nodes on [0, 2], degree rising from 1 to 15, drawn with f on [0, 10.5].

Case 05: \(f(x)=\sqrt{x}\), nodes on \([0, 8]\)

Newton interpolating polynomials of f(x) = √x through equally spaced nodes on [0, 8], degree rising from 1 to 15, drawn with f on [0, 10.5].

Case 06: \(f(x)=\sqrt{x}\), nodes on \([0, 10]\)

Newton interpolating polynomials of f(x) = √x through equally spaced nodes on [0, 10], degree rising from 1 to 15, drawn with f on [0, 10.5].

Case 07: \(f(x)=1/\sqrt{1-x}\), nodes on \([-1.5, 0.95]\)

Newton interpolating polynomials of f(x) = 1/√(1−x) through equally spaced nodes on [−1.5, 0.95], degree rising from 1 to 15, in the window [−1.6, 1.5], with f drawn for x < 1, where it is defined.

Case 08: \(f(x)=1/(1+10x^2)\), nodes on \([-1, 1]\)

Newton interpolating polynomials of f(x) = 1/(1+10x²) through equally spaced nodes on [−1, 1], degree rising from 1 to 15, drawn with f on [−1.5, 1.5].

Case 09: \(f(x)=\ln x\), nodes on \([0.02, 2]\)

Newton interpolating polynomials of f(x) = ln x through equally spaced nodes on [0.02, 2], degree rising from 1 to 15, in the window [−0.5, 4.1], with f drawn for x > 0, where it is defined.

Case 10: \(f(x)=\ln x\), nodes on \([0.02, 4]\)

Newton interpolating polynomials of f(x) = ln x through equally spaced nodes on [0.02, 4], degree rising from 1 to 15, in the window [−0.5, 4.1], with f drawn for x > 0, where it is defined.

Case 11: \(f(x)=\ln(1+x)\), nodes on \([-0.98, 1]\)

Newton interpolating polynomials of f(x) = ln(1+x) through equally spaced nodes on [−0.98, 1], degree rising from 1 to 15, in the window [−1.5, 1.5], with f drawn for x > −1, where it is defined.

Case 12: \(f(x)=\sin x\), nodes on \([-3\pi, 3\pi]\)

With 2, 3 and 4 nodes every node is a multiple of \(\pi\), where \(\sin x = 0\), so every divided difference is zero and the frames titled degree 1, 2 and 3 all show the line \(y = 0\).

Newton interpolating polynomials of f(x) = sin x through equally spaced nodes on [−3π, 3π], degree rising from 1 to 15, drawn with f on the same interval; at degrees 1, 2 and 3 every node is a multiple of π, so the interpolant is the line y = 0.

Case 13: \(f(x)=\cos x\), nodes on \([-3\pi, 3\pi]\)

With 2 and 4 nodes every node is an odd multiple of \(\pi\), where \(\cos x = -1\), so \(a_0 = -1\), every later divided difference is zero, and the frames titled degree 1 and 3 show the line \(y = -1\).

Newton interpolating polynomials of f(x) = cos x through equally spaced nodes on [−3π, 3π], degree rising from 1 to 15, drawn with f on the same interval; at degrees 1 and 3 every node is an odd multiple of π, so the interpolant is the line y = −1.

Case 14: \(f(x)=\tan x\), nodes on \([-1.45, 1.45]\)

\(\tan x\) is odd and the nodes are symmetric about 0, so the middle of three nodes, \((0, 0)\), lies on the line through the two end nodes. Hence \(f[x_0, x_1, x_2] = 0\), and the frames titled degree 1 and 2 show the same line.

Newton interpolating polynomials of f(x) = tan x through equally spaced nodes on [−1.45, 1.45], between the poles of f at x = ±π/2, degree rising from 1 to 15, drawn with f on [−π, π] and broken at its poles; the frames at degrees 1 and 2 show the same straight line.

Case 15: \(f(x)=e^x\), nodes on \([-2, 3]\)

Newton interpolating polynomials of f(x) = eˣ through equally spaced nodes on [−2, 3], degree rising from 1 to 15, drawn with f on the same interval.

Case 16: \(f(x)=e^{-x}\cos x\), nodes on \([-2, 4]\)

Newton interpolating polynomials of f(x) = e⁻ˣ cos x through equally spaced nodes on [−2, 4], degree rising from 1 to 15, drawn with f on the same interval.

Case 17: \(f(x)=\cosh x\), nodes on \([-4, 4]\)

Newton interpolating polynomials of f(x) = cosh x through equally spaced nodes on [−4, 4], degree rising from 1 to 15, drawn with f on the same interval.

Case 18: \(f(x)=\arctan x\), nodes on \([-2, 2]\)

\(\arctan x\) is odd and the nodes are symmetric about 0, so the middle of three nodes, \((0, 0)\), lies on the line through the two end nodes. Hence \(f[x_0, x_1, x_2] = 0\), and the frames titled degree 1 and 2 show the same line.

Newton interpolating polynomials of f(x) = arctan x through equally spaced nodes on [−2, 2], degree rising from 1 to 15, drawn with f on [−2.2, 2.2]; the frames at degrees 1 and 2 show the same straight line.

Case 19: \(f(x)=\arcsin x\), nodes on \([-1, 1]\)

\(\arcsin x\) is odd and the nodes are symmetric about 0, so the middle of three nodes, \((0, 0)\), lies on the line through the two end nodes. Hence \(f[x_0, x_1, x_2] = 0\), and the frames titled degree 1 and 2 show the same line.

Newton interpolating polynomials of f(x) = arcsin x through equally spaced nodes on [−1, 1], degree rising from 1 to 15, in the window [−1.5, 1.5], with f drawn on [−1, 1] (its whole domain); the frames at degrees 1 and 2 show the same straight line.

Case 20: \(f(x)=J_0(x)\), nodes on \([-10, 10]\)

Newton interpolating polynomials of the Bessel function f(x) = J₀(x) through equally spaced nodes on [−10, 10], degree rising from 1 to 15, drawn with f on [−10.2, 10.2].

Case 21: \(f(x)=J_1(x)\), nodes on \([-10.2, 10.2]\)

\(J_1\) is odd and the nodes are symmetric about 0, so the middle of three nodes, \((0, 0)\), lies on the line through the two end nodes. Hence \(f[x_0, x_1, x_2] = 0\), and the frames titled degree 1 and 2 show the same line.

Newton interpolating polynomials of the Bessel function f(x) = J₁(x) through equally spaced nodes on [−10.2, 10.2], degree rising from 1 to 15, drawn with f on the same interval; the frames at degrees 1 and 2 show the same straight line.

Case 22: \(f(x)=e^{-x^2/2}/\sqrt{2\pi}\), nodes on \([-3, 3]\)

Newton interpolating polynomials of the standard normal density f(x) = e^(−x²/2)/√(2π) through equally spaced nodes on [−3, 3], degree rising from 1 to 15, drawn with f on the same interval.

Case 23: \(f(x)=\tfrac12\left(1+\operatorname{erf}(x/\sqrt2)\right)\), nodes on \([-3, 3]\)

\(f(x)-\tfrac12\) is odd and the nodes are symmetric about 0, so the middle of three nodes, \((0, \tfrac12)\), lies on the line through the two end nodes. Hence \(f[x_0, x_1, x_2] = 0\), and the frames titled degree 1 and 2 show the same line.

Newton interpolating polynomials of the standard normal distribution function f(x) = ½(1 + erf(x/√2)) through equally spaced nodes on [−3, 3], degree rising from 1 to 15, drawn with f on the same interval; the frames at degrees 1 and 2 show the same straight line.

Case 24: \(f(x)=\Gamma(x)\), nodes on \([0.05, 2]\)

Newton interpolating polynomials of f(x) = Γ(x) through equally spaced nodes on [0.05, 2], degree rising from 1 to 15, drawn with f on [−0.2, 5.2].

Case 25: \(f(x)=\Gamma(x)\), nodes on \([0.05, 4]\)

Newton interpolating polynomials of f(x) = Γ(x) through equally spaced nodes on [0.05, 4], degree rising from 1 to 15, drawn with f on [−0.2, 5.2].

Case 26: \(f(x)=\Gamma(x)\), nodes on \([0.5, 5]\)

Newton interpolating polynomials of f(x) = Γ(x) through equally spaced nodes on [0.5, 5], degree rising from 1 to 15, drawn with f on [−0.2, 5.2].

Case 27: \(f(x)=Y_0(x)\), nodes on \([0.5, 20]\)

Newton interpolating polynomials of the Bessel function f(x) = Y₀(x) through equally spaced nodes on [0.5, 20], degree rising from 1 to 15, drawn with f on [0, 22].

Case 28: \(f(x)=Y_0(x)\), nodes on \([0.5, 10]\)

Newton interpolating polynomials of the Bessel function f(x) = Y₀(x) through equally spaced nodes on [0.5, 10], degree rising from 1 to 15, drawn with f on [0, 22].

Case 29: \(f(x)=Y_0(x)\), nodes on \([0.5, 4]\)

Newton interpolating polynomials of the Bessel function f(x) = Y₀(x) through equally spaced nodes on [0.5, 4], degree rising from 1 to 15, drawn with f on [0, 22].

Divided differences: \(f(x)=\cos x\), nodes \(x_k = k/5\) on \([0, 1]\)

Behavior: This is Mathews’ Example 1. Each frame adds the next node \(x_n = n/5\) and one more Newton term \(a_n\prod_{j<n}(x-x_j)\); the coefficients already found do not change. The divided differences are \(a_0,\ldots,a_5 = 1,\ -0.0996671,\ -0.488402,\ 0.0490076,\ 0.0381225,\ -0.00396205\). Between the first and last node (shaded) the largest error is \(4.97\times10^{-3}\) at degree 1, \(1.16\times10^{-4}\) at degree 2 and \(1.35\times10^{-6}\) at degree 5, so there the curves coincide in the frames. The frames are drawn on \([-0.5, 2.1]\), as in Mathews’ graphs, so each added term shows to the right of the nodes: the error at \(x = 2.1\) falls from 1.30 at degree 1 to 0.65, 0.32, 0.067 and 0.015, and the degree-2 and degree-3 polynomials leave the bottom of the plot near \(x = 1.81\) and \(x = 1.95\).

Julia source

Newton interpolation of cos x with nodes x_k = k/5 on [0, 1] (Mathews’ Example 1), adding one node per frame from degree 1 (2 nodes) to degree 5 (6 nodes), drawn on [−0.5, 2.1] with the interval [x_0, x_n] shaded; the dashed polynomial passes through every node, its largest error on the shaded interval falls from 4.97e-3 to 1.35e-6, and its gap from cos x to the right of the nodes shrinks from 1.30 to 0.015 at x = 2.1.

References

Mathew, John H. 2000-2019. Numerical Analysis - Numerical Methods Modules. https://web.archive.org/web/20190808102217/http://mathfaculty.fullerton.edu/mathews/n2003/NumericalUndergradMod.html.