Between the samples
Interpolation and Calculus: Differences, Quadrature and Differential Equations

Data arrive as samples, yet calculus lives on continuous functions. The methods in this section bridge the two: fill in values between samples, estimate slopes, add up areas, and follow a differential equation forward in time. Each page ends with an error estimate, since in numerical calculus the error is half of the result.
Interpolation
Given values at a handful of points, interpolation builds a function through them. The one-dimensional interpolation page compares the main choices: straight segments, polynomials and smoother piecewise curves. A warning worth stating early is that a single high-degree polynomial through equally spaced points can oscillate wildly near the ends, so piecewise methods are the safer default. The two-dimensional version applies the same idea on a grid, as when a table of values over two variables needs a value in a gap.
Differences
Slopes and curvature come from finite differences of arbitrary order, combinations of samples with binomial weights. They are simple, and they carry a trade-off between truncation and rounding error that dictates the step size. Differentiation amplifies noise while integration smooths it, which is why measured data are often smoothed or interpolated before differences are taken.
Integration
Quadrature replaces an integral by a weighted sum of function values. Gaussian rules choose both the points and the weights cleverly, so that n points integrate every polynomial up to degree 2n − 1 exactly. The page on two-dimensional Gaussian quadrature extends the rule to areas. Another page covers evaluating special functions through continued fractions with Lentz’s method, a tool that complements series expansions where those converge slowly.
Differential equations
A system of linear differential equations with constant coefficients has the solution y(t) = eAty(0), which turns the problem into computing a matrix exponential. The matrix ODE page shows how a Padé approximation, a ratio of two polynomials, delivers that exponential accurately.
Where to begin
Read interpolation first, since differences and quadrature can both be seen as operations on the interpolating curve. Then differences, then quadrature. Check every method on a function you can handle exactly, such as a low-degree polynomial or the exponential, and compare the observed error with the formula on the page.
Matrix machinery for the last topic lives in linear algebra, and the glossary collects the vocabulary.
Questions about interpolation
What is the difference between interpolation and curve fitting?
An interpolating curve passes exactly through every data point. A fitted curve, such as a least squares line, follows the general trend and may miss every point. Interpolation suits accurate data that must be honored. Fitting suits noisy measurements, where passing through each point would reproduce the noise.
Why does high-degree polynomial interpolation sometimes go wrong?
A single polynomial through many equally spaced points can oscillate wildly near the ends of the interval, which is known as Runge’s phenomenon. The fit is exact at the data but poor between points. Splines, which join low-degree pieces smoothly, avoid this and are the usual choice for many points.
Can I extrapolate with an interpolation formula?
You can evaluate the formula outside the data range, but the result is unreliable. Interpolation errors are bounded between the data points, while beyond them polynomials and splines tend to diverge quickly. If extrapolation is necessary, keep it short, use a low-degree model and treat the output as an estimate.
How accurate is a finite difference derivative?
The error has two parts. A step that is too large causes truncation error from the formula itself. A step that is too small makes rounding error dominate, since two nearly equal numbers are subtracted. For a central difference in double precision, a step near the cube root of machine epsilon, about 10⁻⁵ for unit-sized arguments, balances them.
Evaluating Fractions: Continued Fractions by Lentz's Method
Lentz's method evaluates a continued fraction forward, one level at a time, and stops when the update factor reaches one.
Fibonacci Numbers: Recurrence and Computation
Fibonacci numbers follow F(n+1) = F(n) + F(n−1); three ways to compute them are compared, with exact values and precision limits.
Finite Differences of Arbitrary Order: Formulas, Stencils and Examples
Forward and central finite differences of any order, built from binomial coefficients, with a worked check on e^x and the step-size trade-off.
Matrix ODEs and the Padé Approximation
A linear matrix ODE has the solution exp(At)·x₀; the Padé rational approximation computes the matrix exponential with checked scalar and rotation cases.
One-Dimensional Interpolation (interp1)
One-dimensional interpolation estimates a function between tabulated points; linear and Lagrange examples show how the answer depends on the method.
Running Quotient: Successive Division of a Sequence
The running quotient divides every element of a sequence by its predecessor; it exposes growth rates and recovers the sequence by a cumulative product.
Scripting Numerical Functions
A scripted numerical function takes arguments, checks them, computes with vector operations and returns a tested result; two small examples show the pattern.
Two-Dimensional Gaussian Quadrature
A product of one-dimensional Gauss rules integrates over rectangles and over regions whose x bounds depend on y; two worked cases check the weights.
Two-Dimensional Interpolation (interp2)
Two-dimensional interpolation estimates values between grid points; bilinear weights and a hand-checked cell show how the surface is built.