Interpolation and approximation
Splines, polynomial and rational approximation, and smoothing: representing a function by something simpler.
Interpolate 1/(1 + 25x²) through 21 equally spaced points between -1 and 1 with one polynomial of degree 20, and near the ends the polynomial misses the function by 60, for a function that never exceeds 1. Move the same 21 points to the Chebyshev nodes, which crowd toward the ends, and the error falls to 0.015; a cubic spline through the original points gets to 0.003. The swings at the edges are called Runge's phenomenon, and they are why this topic is more than drawing a curve through points.
What people bring here is a function known at a few places and wanted everywhere: a thermocouple calibration table, a potential energy surface computed at a few hundred molecular geometries, rock density logged at irregular depths in a borehole, a growth curve with one reading per day, a special function too slow to call a million times inside a simulation.
In Python, scipy.interpolate has CubicSpline and make_interp_spline for curves, make_smoothing_spline for noisy samples, RegularGridInterpolator for grids in several dimensions, RBFInterpolator for scattered points, BarycentricInterpolator for stable polynomial interpolation, and pade and AAA for rational approximation. numpy.polynomial.Chebyshev.interpolate samples a function at the Chebyshev nodes and returns its series. In Julia, Interpolations.jl covers gridded data, and ApproxFun.jl turns a smooth function into a Chebyshev or Fourier series that you can then differentiate and integrate.
Never put one high-degree polynomial through equally spaced data. Use a spline, or sample at Chebyshev nodes when you choose where to evaluate. Start with spline interpolation of a table, then Chebyshev nodes and why they work, then smoothing splines for noisy data. A model with physical parameters and error bars is curve fitting, and derivatives and integrals are numerical calculus.
What belongs here
Representing data or a function by something you can evaluate anywhere: interpolation with polynomials and splines, Chebyshev approximation, rational and Padé approximants, smoothing splines, and the error each one makes. Fitting a physical model with uncertain parameters belongs to curve-fitting; derivatives, quadrature, and root finding to numerical-calculus.
0 tutorials by type and language
| Python | Julia | |
|---|---|---|
| Concept | – | – |
| Tool | – | – |
| Recipe | – | – |
| Visualization | – | – |
| Project | – | – |