Foundations to Frontier
Tests
A. Mathematical Foundations › A8 Numerical Methods and Scientific Computing

Interpolation and Splines

Interpolation builds a function that passes exactly through given data: sensor calibration tables, ephemerides sampled at discrete times, robot waypoints. You will learn polynomial interpolation in Lagrange and barycentric form, the interpolation error formula, the Runge phenomenon and its cure with Chebyshev nodes, and cubic splines with their O(h⁴) accuracy and minimum-curvature property. In the research exercise you generate a smooth, rest-to-rest joint trajectory through waypoints with a clamped cubic spline and compare its accelerations with a single high-degree polynomial.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Connect the dots, smoothly

You have a few dots on a page and want a smooth curve through all of them. A ruler gives straight segments with sharp corners. One big curvy formula might wiggle wildly between dots. The engineer’s answer is a spline, named after the flexible strips of wood shipbuilders bent through pegs: gentle curves, joined so smoothly you can’t see the seams.

Connect the dots: polynomials, splines and the Runge phenomenon
max error on [−1, 1]: 1.92e+0 (curve clipped)
A single high-degree polynomial through equispaced points oscillates wildly near the ends for the Runge function, and adding points makes it worse. Clustering nodes like Chebyshev points (denser at the ends) fixes that and converges fast for smooth functions. Cubic splines join low-degree pieces with continuous slope and curvature: robust on any node set, with O(h⁴) error. The |x| kink limits every method.
Why engineers care

Robot arms and drones follow splines through waypoints, because corners would demand infinite acceleration. Spacecraft ephemerides (SPICE kernels) store planetary positions as piecewise Chebyshev polynomials. Sensor calibration curves, CAD surfaces and camera lens-distortion maps are all interpolants.

📝 Quick check (Level 0)
0/3 answered
  1. 1. An interpolant must…
  2. 2. Straight segments between waypoints give a robot…
  3. 3. A spline is made of…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Polynomial interpolation

Through n+1n + 1 points with distinct xix_i there is exactly one polynomial of degree ≤ n. In Lagrange form,

p(x)=∑j=0nyjℓj(x),ℓj(x)=∏m≠jx−xmxj−xmp(x) = \sum_{j=0}^ny_j\ell_j(x),\quad\ell_j(x) = \prod_{m\ne j}\frac{x - x_m}{x_j - x_m}

The barycentric form p(x)=∑jwjyj/(x−xj)∑jwj/(x−xj)p(x) = \frac{\sum_jw_jy_j/(x - x_j)}{\sum_jw_j/(x - x_j)}, with wj=1/∏m≠j(xj−xm)w_j = 1/\prod_{m\ne j}(x_j - x_m), evaluates it in O(n)O(n) per point and is numerically stable (Berrut and Trefethen, 2004).

Piecewise linear

Simple and robust, with error ≤h28max⁡∣f′′∣\le\frac{h^2}8\max\lvert f''\rvert, but the derivative jumps at every node.

📝 Quick check (Level 1)
0/3 answered
  1. 1. How many polynomials of degree ≤ 2 pass through 3 points with distinct x?
  2. 2. The Lagrange basis ℓⱼ(xᵢ) equals…
  3. 3. Piecewise-linear error scales like…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 40 minUndergraduate students and practising engineers.

Interpolation error and the Runge phenomenon

f(x)−p(x)=f(n+1)(ξ)(n+1)!∏i=0n(x−xi)f(x) - p(x) = \frac{f^{(n+1)}(\xi)}{(n + 1)!}\prod_{i=0}^n(x - x_i)

For equispaced nodes the node polynomial ∏(x−xi)\prod(x - x_i) is huge near the ends. For 1/(1+25x2)1/(1 + 25x^2) the error grows with n (Runge, 1901). Chebyshev nodes xk=cos⁡(2k+1)π2nx_k = \cos\frac{(2k + 1)\pi}{2n} minimize max⁡∣∏(x−xi)∣\max\lvert\prod(x - x_i)\rvert and give geometric convergence for analytic f. That’s the basis of Chebfun and of JPL ephemeris storage.

Cubic splines

Use one cubic per interval, matching values and requiring continuous first and second derivatives. With second derivatives MiM_i at the nodes, continuity of s′s' gives a tridiagonal system

hi−1Mi−1+2(hi−1+hi)Mi+hiMi+1=6(yi+1−yihi−yi−yi−1hi−1)h_{i-1}M_{i-1} + 2(h_{i-1} + h_i)M_i + h_iM_{i+1} = 6\Big(\frac{y_{i+1} - y_i}{h_i} - \frac{y_i - y_{i-1}}{h_{i-1}}\Big)

End conditions:

  • natural: M0=Mn=0M_0 = M_n = 0;
  • clamped: prescribed end slopes, e.g. zero velocity at rest;
  • not-a-knot.

The error is O(h4)O(h^4).

🐍 Exercise 1: Runge, Chebyshev and splines
Implement barycentric interpolation, Chebyshev nodes and natural cubic splines. Reproduce the Runge phenomenon, its cure with Chebyshev nodes, and the spline's robustness. Measure the O(h⁴) spline convergence.
📝 Quick check (Level 2)
0/3 answered
  1. 1. The Runge phenomenon is cured by…
  2. 2. Cubic splines solve a linear system that is…
  3. 3. A clamped spline prescribes…

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Proof of the error formula

Fix xx not a node and let g(t)=f(t)−p(t)−K∏(t−xi)g(t) = f(t) - p(t) - K\prod(t - x_i), with KK chosen so that g(x)=0g(x) = 0. Then gg has n+2n + 2 zeros. By Rolle, g(n+1)g^{(n+1)} has a zero ξ\xi, and g(n+1)(ξ)=f(n+1)(ξ)−K(n+1)!=0g^{(n+1)}(\xi) = f^{(n+1)}(\xi) - K(n + 1)! = 0. ∎

Minimum curvature of the natural spline

Among all C2C^2 functions interpolating the data, the natural cubic spline minimizes ∫(f′′)2\int(f'')^2. Write f=s+ef = s + e with e(xi)=0e(x_i) = 0. Integration by parts on each interval gives ∫s′′e′′=0\int s''e'' = 0 (it uses s′′′s''' piecewise constant and s′′s'' zero at the ends). So ∫f′′2=∫s′′2+∫e′′2≥∫s′′2\int f''^2 = \int s''^2 + \int e''^2\ge\int s''^2. ∎ (de Boor, 1978.) The clamped spline has the same property among interpolants with the same end slopes.

Chebyshev optimality

21−nTn(x)=∏(x−xk)2^{1-n}T_n(x) = \prod(x - x_k) over the Chebyshev nodes has the smallest maximum, 21−n2^{1-n}, of all monic degree-nn polynomials on [−1, 1].

Exercise 3.1: quadratic through (0, 1), (1, 3), (2, 7)

p(x)=x2+x+1p(x) = x^2 + x + 1, so p(3)=13p(3) = 13.

📝 Quick check (Level 3)
0/3 answered
  1. 1. The interpolation error proof uses…
  2. 2. The natural spline minimizes…
  3. 3. max|∏(x − xₖ)| over Chebyshev nodes on [−1, 1] equals…

Level 4: Expert

★★★★★ Expert⏱ 35 minResearchers: original papers and open problems.

Rest-to-rest joint trajectory through waypoints

A robot joint must pass through 10 waypoints at 1-second intervals, starting and stopping at rest. The clamped cubic spline with zero end velocities is C2C^2 (continuous acceleration, so no torque jumps). It hits every waypoint, and its peak acceleration is about 4× lower than a single degree-9 polynomial’s, which also can’t satisfy the rest conditions. Linear interpolation is worse still: velocity jumps at every waypoint mean impulsive torques. Industrial and space manipulators use cubic or quintic splines (C⁴ for jerk-limited motion) or B-splines with time-optimal parametrization.

🐍 Exercise 2 (research): spline trajectory generation
Build a clamped cubic spline through joint waypoints and evaluate position, velocity and acceleration. Verify rest-to-rest endpoints and C² continuity. Compare peak acceleration and bending energy with a degree-9 polynomial interpolant.

Interpolation in AI, robotics and aerospace

  • Trajectory generation: cubic and quintic splines and minimum-snap polynomials for quadrotors (Mellinger and Kumar, 2011); B-splines in motion planners.
  • Ephemerides: JPL DE ephemerides and SPICE kernels store positions as Chebyshev series over fixed time intervals.
  • Calibration and lookup tables: thruster curves and aerodynamic tables are interpolated in flight software (often with linear or monotone cubic interpolation to avoid overshoot).
  • Machine learning: kernel and RBF interpolation, and neural implicit representations as learned interpolants.

References

  1. J.-P. Berrut, L. N. Trefethen (2004). “Barycentric Lagrange interpolation.” SIAM Review, 46(3).
  2. L. N. Trefethen (2019). Approximation Theory and Approximation Practice, extended ed. SIAM.
  3. C. de Boor (1978). A Practical Guide to Splines. Springer.
  4. C. Runge (1901). “Über empirische Funktionen und die Interpolation zwischen äquidistanten Ordinaten.” Zeitschrift für Mathematik und Physik, 46.
  5. D. Mellinger, V. Kumar (2011). “Minimum snap trajectory generation and control for quadrotors.” ICRA.
  6. B. Siciliano, L. Sciavicco, L. Villani, G. Oriolo (2009). Robotics: Modelling, Planning and Control. Springer. Ch. 4.
  7. C. Acton (1996). “Ancillary data services of NASA’s Navigation and Ancillary Information Facility.” Planetary and Space Science, 44(1).
  8. F. Fritsch, R. Carlson (1980). “Monotone piecewise cubic interpolation.” SIAM J. Numerical Analysis, 17(2).