Interpolation · CMNA Laboratory

One set of points. Three very different curves.

Paste data into R, then compare a global polynomial, local line segments, and a natural cubic spline across exactly the same samples.

Interpolation is a modeling choice.

All three methods pass through the data. What changes is what they assume between observations: one global polynomial, independent local lines, or smooth local cubics joined together.

Bring your own data

Define x and y in R.

The lab builds all three interpolants in R and lets you sweep across x to compare their values.

RuntimePreparing R…
RDefine numeric vectors x and y
PolynomialPiecewise linearCubic spline

pointxy
Book§4.1–4.2 · Polynomial and Piecewise Interpolation · pp. 89–103Book details
CMNA packagepolyinterppwiselinterpcubicspline
TeachingInstructor notes and chapter contextOpen teaching material
Numerical ZooWorked problems