Rational interpolation and approximation
| Problem | Approximate a function by a ratio of polynomials , from samples or from a Taylor series, so as to capture poles, steep gradients and behaviour beyond the reach of polynomials |
| Devised by | Padé approximants: Henri Padé (1892), after Jacobi and Frobenius. Rational extrapolation: Roland Bulirsch and Josef Stoer (1964). Barycentric rational interpolation: Jean-Paul Berrut (1988), Michael Floater and Kai Hormann (2007). AAA: Yuji Nakatsukasa, Olivier Sète and Lloyd N. Trefethen (2018) |
| Accuracy | Floater-Hormann: on any points. Bulirsch-Stoer and AAA: often geometric, exact for rational functions of sufficient degree. Padé: matches the Taylor series to order |
| Cost | Floater-Hormann: weights, per point. Bulirsch-Stoer: per point. AAA: an SVD per added term. Padé: one linear solve |
| Read first | Polynomial interpolation |
| API | FloaterHormann, BulirschStoer, AaaApproximation, PadeApproximant |
Overview
A polynomial can never become infinite, and it grows without bound as . Many functions do not behave like that: they have poles, approach constants, or change steeply near singularities just off the interval of interest. A rational function, a ratio of two polynomials, can do all of these things, and so rational approximations are often dramatically better than polynomial ones of the same number of parameters.
The library offers four rational methods for different situations. Floater-Hormann interpolation is a robust, pole-free alternative to polynomial interpolation at equally spaced or irregular points. Bulirsch-Stoer interpolation builds the diagonal rational interpolant through all the data and estimates its own error. The AAA algorithm chooses a small set of support points automatically and finds a near-best rational approximation to sampled data. Padé approximants turn a Taylor series into a rational function that is often accurate far beyond the series’ radius of convergence.
Where it is used
Rational functions approximate functions with poles and long tails far better than polynomials.
- Mathematical software. Library implementations of special functions use rational approximations because they need few operations for high accuracy.
- Control and circuits. Transfer functions are rational, and fitting a rational model to frequency-response data (vector fitting, Pade) is common in system identification and model-order reduction.
- Pade approximants. Turning a Taylor series into a function that remains accurate far beyond its radius of convergence.
History
Rational approximations of power series were studied by Jacobi and Frobenius, but it was Henri Padé’s 1892 thesis that organised them into the Padé table of all approximants and studied its structure. Padé approximants became a standard tool of theoretical physics in the twentieth century, for summing divergent perturbation series.
Roland Bulirsch and Josef Stoer (1964) devised a recursive tableau, like Neville’s algorithm for polynomials, for evaluating the diagonal rational interpolant, and used it in their extrapolation method for differential equations. Barycentric rational interpolation grew from Jean-Paul Berrut’s observation (1988) that changing the weights of the barycentric formula gives rational interpolants guaranteed to have no poles; Michael Floater and Kai Hormann (2007) found the family of such interpolants with arbitrarily high order. Most recently, Yuji Nakatsukasa, Olivier Sète and Nick Trefethen’s AAA algorithm (2018, “adaptive Antoulas-Anderson”) combined the barycentric form with greedy point selection and least squares, and made rational approximation practical and automatic.
The idea
Barycentric rational functions
Three of the four methods rest on one observation about the barycentric formula
For polynomial interpolation the weights were given by a specific formula. But the expression interpolates the data for any nonzero weights. To see why, let approach a node . The term with grows without bound in both sums and swamps all the others, so
The weight cancels: its value does not matter, as long as it is not zero.
What the weights do control is the behaviour between the nodes. Multiplying numerator and denominator by shows that is a ratio of two polynomials of degree at most , that is, a rational function. Only for the special weights does the denominator reduce to a constant, making a polynomial. So the weights are free parameters, and the question becomes how to choose them. Floater-Hormann interpolation and AAA give two different answers.
Floater-Hormann interpolation
A single polynomial through many equally spaced points oscillates, but a polynomial of low degree through just neighbouring points is well behaved. Floater and Hormann’s idea is to blend these local interpolants. Let be the polynomial of degree through the run of consecutive points . The interpolant is the weighted average
The blending function is large when is near the points of run , so each local polynomial dominates in its own neighbourhood. The alternating signs are what make the denominator free of real zeros.
Rewriting this average in barycentric form (collecting the coefficient of each ) gives the weights
where is the set of runs that contain . The formula looks complicated, but it only says: for each run containing , take the polynomial barycentric weight of within that run, and add them up. The interpolant has three useful properties.
- It has no real poles, for any and any distribution of points.
- It converges like for smooth functions, where is the largest spacing. This is the accuracy of the local polynomials.
- With there is only one run, and it reduces to the polynomial interpolant.
A moderate (3 to 8) combines high order with stability at equally spaced points, exactly where polynomials fail.
Bulirsch-Stoer rational interpolation
Bulirsch and Stoer take the opposite approach: instead of choosing weights, they ask for the rational function through all points whose numerator and denominator have equal degrees (or degrees differing by one, when is even). This is the diagonal rational interpolant, and its coefficients are fixed by the data points.
The interpolant is never written down. As in Neville’s algorithm for polynomials, its value at a given is built up in a triangular tableau. The first column holds the data values; each later column combines neighbouring entries of the previous one into the value at of an interpolant through one more point, raising the degree of the numerator or the denominator by one. The size of the last correction applied is an estimate of the error.
The evaluation costs per point. A rational function can have poles, and a pole of the interpolant at the evaluation point is reported as an error. When the data come from a rational function of lower degree, later corrections vanish and the library stops early; the error estimate is then at rounding level.
The AAA algorithm
AAA (for “adaptive Antoulas-Anderson”, pronounced “triple-A”) approximates sampled data , , by a barycentric rational function that interpolates only at a few chosen samples, the support points with values , and fits the rest in a least-squares sense. Write the approximant as with
We would like at the remaining samples. That condition is nonlinear in the weights. Multiplying through by gives , which is linear in the weights:
is called the Loewner matrix. The weights can be rescaled without changing , so we fix and minimise . The minimiser is the right singular vector of belonging to its smallest singular value, read off from a singular value decomposition. The algorithm is then a greedy loop:
- Start with no support points and the approximation equal to the mean of .
- Find the sample where the current approximation is worst and make it a support point, so that the approximant now interpolates it.
- Form the Loewner matrix over the remaining samples and take the weights from its smallest singular vector.
- Repeat until the error at all samples is below the tolerance.
AAA typically finds an approximation within a few digits of the best rational approximation, with remarkably few terms, and works on any set of sample points, real or complex. Its main pitfall is spurious poles: occasionally a pole and a nearby zero almost cancel (a Froissart doublet), producing a narrow spike between samples. Production codes detect such doublets and remove them; the library leaves this to the user.
Rational methods on equally spaced data
The Runge function sampled at equally spaced points defeats polynomial interpolation (see polynomial interpolation). The rational methods succeed:
Figure 3.7. Rational interpolation of the Runge function.
Floater-Hormann with converges algebraically, as its theory promises. Bulirsch-Stoer and AAA
reach machine precision with about twenty points, but this is partly a special case: the Runge
function is itself rational, of type , so any rational method of sufficient degree recovers it
exactly. For non-rational functions with nearby singularities they still converge geometrically, as
the tan x example below shows.
Padé approximants
The methods above start from samples. A Padé approximant starts from a Taylor series . The Padé approximant is the rational function , with numerator of degree , denominator of degree and , whose own Taylor series agrees with that of through the term . It has free coefficients and matches terms of the series.
Finding the coefficients. Requiring to that order is the same as requiring
which is linear in the unknown coefficients and . Multiply out and compare powers of . The coefficient of in the product is (with ).
- For the powers the polynomial contributes nothing, so the coefficient of the product must vanish by itself. This gives an linear system for the denominator:
- For the powers the coefficient of the product must equal , which gives the numerator directly: .
A small example. For and , the system is the single equation , so . Then and :
which agrees with the series of through , as promised.
Why it works so well. A power series converges only inside a disc that reaches to the nearest singularity of . A rational function can have poles of its own, and it places them so as to mimic the singularities of ; the approximant is then often accurate far outside the disc. For , whose Taylor series converges only for , the approximant built from the same 21 coefficients remains accurate far beyond:
Table 3.6. Taylor polynomial against Padé approximant for .
| Taylor polynomial, degree 20: error | Padé : error | ||
|---|---|---|---|
| 0.5 | 0.4054651081 | 1.5e-8 | 5.6e-17 |
| 0.9 | 0.6418538862 | 2.8e-3 | 2.2e-16 |
| 1 | 0.6931471806 | 2.4e-2 | 4.4e-16 |
| 2 | 1.0986122887 | 3.4e4 | 5.9e-12 |
| 5 | 1.7917594692 | 3.9e12 | 7.5e-8 |
| 20 | 3.0445224377 | 5.0e24 | 5.3e-4 |
Algorithm
Floater-Hormann. Input: points in increasing order and the blending degree .
- Set-up. For each node , sum over the runs of consecutive nodes that contain it the reciprocal of the product of the distances from to the other nodes of the run, and attach the sign . Cost: .
- Evaluation. The barycentric formula, unchanged. Cost: per point.
Bulirsch-Stoer. There is no set-up. For each evaluation point :
- find the data point nearest to ; if coincides with it, return its value;
- initialise the first column of the tableau with the data values;
- for each further column, combine neighbouring entries of the previous column into the corrections for interpolants through one more point, and add the correction that lies on the path leading away from the nearest point to the running value;
- stop early when a correction is at rounding level; report an error if a denominator vanishes (a pole at );
- return the value, with the last correction as the error estimate.
Cost: per point.
AAA. Input: samples , a relative tolerance and a maximum number of terms.
- Set the approximation to the mean of the , and the support set to empty.
- Find the sample with the largest current error. If that error is below the tolerance times the largest , or the term limit has been reached, stop.
- Move that sample into the support set.
- Build the Loewner matrix, with one row for each remaining sample and one column for each support point.
- Compute its SVD and take the right singular vector of the smallest singular value as the weights.
- Evaluate the new approximation at the remaining samples, and go to 2.
With samples and support points at the end, the cost is , dominated by the SVDs.
Padé. Input: Taylor coefficients .
- Solve the linear system for (with ); report an error if it is singular.
- Form for .
- To evaluate, compute and by Horner’s rule and divide.
Implementation
The core of the AAA iteration:
// Loewner matrix on the remaining points.
let a = Array2::from_shape_fn((remaining.len(), k), |(i, j)| {
let (r, s) = (remaining[i], support[j]);
(f[r] - f[s]) / (z[r] - z[s])
});
let (_, _, vt) = a.svd(false, true).map_err(|_| ErrorsJSL::RuntimeError("SVD failed"))?;
let vt = vt.ok_or(ErrorsJSL::RuntimeError("SVD returned no right vectors"))?;
weights = vt.row(vt.nrows() - 1).to_vec();
- All four methods require distinct abscissas; Floater-Hormann also requires them in increasing order.
- The AAA weights come from the SVD in
lib_jsl_linalg. - The Padé system can be singular, when the Taylor coefficients make the requested degenerate; the constructor then reports an error, and a neighbouring entry of the Padé table should be used.
In practice
//! Rational interpolation and approximation: Floater-Hormann, Bulirsch-Stoer, AAA and Padé.
//!
//! Run with `cargo run -p lib_jsl_interpolation --example interpolation_rational`.
use lib_jsl_core::R1D;
use lib_jsl_interpolation::interpolation_trait::InterpolationTrait;
use lib_jsl_interpolation::one_d::aaa::AaaApproximation;
use lib_jsl_interpolation::one_d::bulirsch_stoer::BulirschStoer;
use lib_jsl_interpolation::one_d::floater_hormann::FloaterHormann;
use lib_jsl_interpolation::one_d::pade_approximants::PadeApproximant;
fn main() {
// tan x on [0, 1.5] has a pole just beyond the interval, at π/2 ≈ 1.5708.
let n = 31;
let xs: Vec<f64> = (0..n).map(|i| 1.5 * i as f64 / (n - 1) as f64).collect();
let (x, y) = (R1D::from_vec(xs.clone()), R1D::from_vec(xs.iter().map(|v| v.tan()).collect()));
let max_err = |f: &mut dyn FnMut(f64) -> f64| (0..=1500).map(|i| { let t = i as f64 / 1000.0; (f(t) - t.tan()).abs() / t.tan().abs().max(1.0) }).fold(0.0, f64::max);
let mut fh = FloaterHormann::new(x.view(), y.view(), 4).unwrap();
let mut bs = BulirschStoer::new(x.view(), y.view()).unwrap();
let aaa = AaaApproximation::new(x.view(), y.view(), 1e-13, 30).unwrap();
println!("tan x from {n} equally spaced samples on [0, 1.5], maximum relative error:");
println!(" Floater-Hormann (d = 4): {:.1e}", max_err(&mut |t| fh.interpolate_at(t).unwrap()));
println!(" Bulirsch-Stoer: {:.1e}", max_err(&mut |t| bs.interpolate_at(t).unwrap()));
println!(" AAA ({} terms): {:.1e}", aaa.terms(), max_err(&mut |t| aaa.evaluate(t)));
// A Bulirsch-Stoer value with its error estimate.
let (v, e) = bs.interpolate_with_error(1.2).unwrap();
println!("Bulirsch-Stoer at 1.2: {v:.14} ± {e:.1e} (tan 1.2 = {:.14})", 1.2f64.tan());
// Padé: e^x from its Taylor series, [4/4] against the degree-8 Taylor polynomial at x = 3.
let taylor: Vec<f64> = (0..=8).scan(1.0, |f, k| { let c = 1.0 / *f; *f *= (k + 1) as f64; Some(c) }).collect();
let pade = PadeApproximant::new(&taylor, 4, 4).unwrap();
let polynomial: f64 = taylor.iter().enumerate().map(|(k, c)| c * 3f64.powi(k as i32)).sum();
println!("e³ = {:.6}: Taylor {:.6}, Padé [4/4] {:.6}", 3f64.exp(), polynomial, pade.evaluate(3.0));
}
Strengths
- Poles, steep gradients and asymptotic behaviour are captured with few parameters.
- Floater-Hormann gives stable, high-order interpolation on equally spaced data.
- AAA is automatic and often near-optimal; Padé extends power series beyond their radius of convergence.
Weaknesses
- Rational interpolants other than Floater-Hormann may have poles in the interval (Bulirsch-Stoer reports them; AAA may produce spurious ones).
- Bulirsch-Stoer costs per evaluation.
- Padé systems can be ill-conditioned or singular, and the approximants may have spurious poles too.
Exercises
- Show that the barycentric formula interpolates at for any nonzero weights.
- Compute the Floater-Hormann weights for (Berrut’s interpolant) on equally spaced points and show they are up to a constant.
- Compute the Padé approximant of and compare it with the degree-2 Taylor polynomial at .
- Use AAA on samples of at 1000 points in . How many terms are needed for ? Where do the poles of the approximant lie? (Newman showed in 1964 that rational approximation of converges like , far faster than polynomials.)
- Find data for which AAA produces a Froissart doublet, and remove it by deleting the corresponding support point and refitting.
Hints and answers
- As the -th term dominates both sums, so the ratio tends to whatever is.
- For the Floater-Hormann weights on equally spaced points are up to a constant factor (Berrut’s first interpolant).
- : . At this gives against the true , an error of ; the degree-2 Taylor polynomial gives , an error of . The Padé form has the same number of parameters but is not better here; its advantage is near poles and for large arguments.
- Expect the poles to lie close to the imaginary axis and to cluster towards , as in Newman’s construction. Count the support points the algorithm adds before the residual falls under and compare with the degree a polynomial would need.
- A Froissart doublet is a pole and zero that almost cancel. They appear when the tolerance is set below the noise level of the data, so add noise of size about and ask for a tolerance of .
Further reading
- H. Padé, Sur la représentation approchée d’une fonction par des fractions rationnelles, thesis, Paris, 1892.
- R. Bulirsch and J. Stoer, “Fehlerabschätzungen und Extrapolation mit rationalen Funktionen bei Verfahren vom Richardson-Typus”, Numerische Mathematik 6 (1964) 413–427.
- M. S. Floater and K. Hormann, “Barycentric rational interpolation with no poles and high rates of approximation”, Numerische Mathematik 107 (2007) 315–331.
- Y. Nakatsukasa, O. Sète and L. N. Trefethen, “The AAA algorithm for rational approximation”, SIAM Journal on Scientific Computing 40 (2018) A1494–A1522.
- G. A. Baker and P. Graves-Morris, Padé Approximants, 2nd ed., Cambridge University Press, 1996.