Trigonometric interpolation and Prony’s method
| Problem | Interpolate equally spaced samples by sums of sines and cosines (periodic data), or of damped complex exponentials (decaying oscillations) |
| Devised by | Trigonometric interpolation: Alexis Clairaut (1754), Joseph-Louis Lagrange (1762), Carl Friedrich Gauss (1805, including the first FFT); Prony’s method: Gaspard de Prony (1795) |
| Accuracy | Trigonometric: exponential for smooth periodic functions. Prony: exact for exact exponential sums; with noise, reliable when more exponentials are fitted than the signal contains |
| Cost | Trigonometric: set-up (a direct DFT), per evaluation. Prony: two least-squares problems and an eigenvalue problem of the model order |
| Read first | Preliminaries: complex numbers, The fast Fourier transform |
| API | FourierInterpolator1D, PronyModel |
Overview
Polynomials are the natural building blocks for functions on an interval. For functions that repeat, or that oscillate and decay, other building blocks fit far better. Trigonometric interpolation passes a finite Fourier series through equally spaced samples of a periodic function; for smooth periodic functions it converges exponentially, and it is the reason the discrete Fourier transform is such a powerful tool.
Prony’s method goes one step further: it fits a sum of damped oscillations with unknown frequencies and damping rates, determined from the data themselves. That makes it both an interpolator and a spectral analysis tool that can resolve frequencies more finely than the Fourier transform of the same samples, and extrapolate the signal beyond the data.
Where it is used
Periodic data and sums of exponentials call for trigonometric models.
- Periodic signals. Interpolating a sampled waveform, an annual temperature cycle or a rotating machine’s vibration by sines and cosines.
- Prony’s method. Fitting damped sinusoids to a transient response estimates natural frequencies and damping of structures (modal analysis), radar target resonances, and NMR spectra.
- Resampling. Shifting a periodic signal by a fraction of a sample without aliasing.
History
Trigonometric interpolation was developed in the eighteenth century to predict the motions of planets and comets, which are periodic. Clairaut (1754) and Lagrange (1762) gave formulas for the coefficients, and in 1805 Gauss, computing the orbits of the asteroids Pallas and Juno, devised an efficient way to evaluate them that is now recognised as the first fast Fourier transform, a century and a half before Cooley and Tukey.
Gaspard de Prony, an engineer of the French revolutionary government, published his method in 1795 in a study of the expansion of gases, fitting measured pressures with sums of exponentials. It remained a curiosity until the age of digital signal processing, when it became the ancestor of the linear prediction and high-resolution spectral estimation methods (Pisarenko, MUSIC, ESPRIT, the matrix pencil) used in radar, speech and the analysis of vibrations.
The idea
Trigonometric interpolation
Suppose is periodic with period , and we have samples at the equally spaced points covering one period. We look for an interpolant made of the simplest periodic functions, the complex exponentials with integer frequency (each is a sine and a cosine with cycles per period).
With samples we can determine coefficients. They are given by the discrete Fourier transform (DFT),
and the inverse DFT states precisely that the samples are recovered from them: . Since , this says that the Fourier series with coefficients passes through every sample.
Which frequencies? There is a subtlety. At the sample points, frequency and frequency are indistinguishable, because and the last factor is 1. This is aliasing (the same phenomenon as in sampled signals). Any set of consecutive frequencies would interpolate the samples, but they would behave very differently between the samples. The right choice is the set of lowest frequencies, from to , which wiggles as little as possible:
Two details of this formula deserve a comment.
- For real data, is the complex conjugate of , so the terms for and add up to a real cosine and sine. Pairing keeps the interpolant real.
- For even the highest frequency , the Nyquist frequency, has no partner: and are aliases of each other. Splitting its coefficient evenly between the two gives the cosine term in brackets.
The interpolant passes through every sample, and it contains no frequencies higher than the samples can resolve.
Accuracy. For a smooth periodic the Fourier coefficients decay exponentially, and so does the interpolation error: 24 samples of give a maximum error of . For data that are not periodic, the interpolant still assumes that the function repeats, so it sees a jump between the last sample and the first. A Fourier series converges slowly at a jump and overshoots on both sides of it, the Gibbs oscillations visible near the ends:
Figure 3.8. Trigonometric interpolation.
Prony’s method
Trigonometric interpolation fixes the frequencies in advance and finds the amplitudes. Prony’s method treats the frequencies and the decay rates as unknowns too. The model is a sum of complex exponentials sampled at interval ,
The real part of is a growth (or, if negative, decay) rate and the imaginary part is an angular frequency. Fitting the directly would be a difficult nonlinear problem. Prony’s insight was that it can be avoided.
The key observation. Start with one exponential, . Each sample is times the one before: . The samples satisfy a linear recurrence whose coefficient reveals . The same is true for exponentials. Let
be the polynomial whose roots are . Then for every ,
because each is a root of . In words: every sample is a fixed linear combination of the samples before it. The combination is the same everywhere in the signal, and its coefficients encode the poles .
The method. This turns one nonlinear problem into three linear ones.
- Linear prediction. Write the recurrence for every available . The samples are known and are unknown, so this is a system of linear equations, usually with more equations than unknowns, solved by least squares.
- Poles. The are the roots of , computed as the eigenvalues of its companion matrix. Taking the logarithm, , gives the decay rate and the frequency of each component.
- Amplitudes. With the known, the model is linear in the : another least-squares problem, with a Vandermonde matrix of entries .
For an exact exponential sum, step 1 needs equations, each involving consecutive samples, so samples suffice to recover every frequency and damping rate exactly, however close the frequencies are. A Fourier transform, by contrast, cannot separate two frequencies closer than about one cycle over the length of the record. This is why Prony’s method can outperform Fourier analysis on short records.
Prony’s method and noise
The price of this resolution is sensitivity to noise. With measurement noise the recurrence no longer holds exactly, and fitting exactly as many exponentials as the signal contains often gives nonsense. The remedy, analysed by Ramdas Kumaresan and Donald Tufts, is to fit more exponentials than expected: the extra poles absorb the noise as heavily damped components, and the true ones emerge accurately. On data with 2% noise:
Table 3.7. Damped sinusoids recovered by Prony's method.
| model | oscillatory components found: damping, frequency (Hz) |
|---|---|
| true signal | 0.100, 0.450 Hz; 0.300, 1.200 Hz |
| 4 exponentials | 0.653, 1.174 Hz |
| 8 exponentials | 0.103, 0.450 Hz; 0.304, 1.200 Hz; 1.355, 3.123 Hz; 1.825, 4.460 Hz |
Figure 3.9. Prony's method on noisy data.
With four exponentials (the true number) the fit finds a single, wrong oscillation. With eight it recovers both true components to within a few per cent, and its extrapolation follows the true signal long after the data end.
Algorithm
Trigonometric interpolation. Input: samples covering one period from .
- Set-up. Compute the coefficients by the DFT sum. Cost: as a direct sum, once.
- Evaluation at . Add the constant ; for each from 1 to just below , add the pair of terms for and , which for real data is ; for even add the Nyquist cosine term. Because every term has period , the result is automatically periodic. Cost: per point.
Prony’s method. Input: equally spaced samples and the number of exponentials (with ).
- Linear prediction. Form the system whose row states , and solve it by least squares.
- Poles. Form the companion matrix of and compute its eigenvalues .
- Amplitudes. Form the matrix with entries and solve for the complex amplitudes by least squares.
- Evaluation at . Return . The same formula extrapolates beyond the data.
The cost is dominated by the two least-squares solves, , and the eigenvalue computation, .
Implementation
// Linear prediction: y[k+p] = -Σ_{j=1..p} a_j y[k+p-j] for k = 0..n-p.
let rows = n - order;
let a = Array2::from_shape_fn((rows, order), |(k, j)| y[k + order - 1 - j]);
let b = Array1::from_shape_fn(rows, |k| -y[k + order]);
let coef = a
.least_squares(&b)
.map_err(|_| ErrorsJSL::RuntimeError("prediction least squares failed"))?
.solution;
// Poles are the roots of z^p + a_1 z^(p-1) + ... + a_p: eigenvalues of the companion matrix.
let mut companion = Array2::<f64>::zeros((order, order));
for j in 0..order {
companion[[0, j]] = -coef[j];
}
for i in 1..order {
companion[[i, i - 1]] = 1.0;
}
let (eigenvalues, _) = companion.eig().map_err(|_| ErrorsJSL::RuntimeError("eigenvalue solve failed"))?;
let poles: Vec<Complex<f64>> = eigenvalues.to_vec();
// Amplitudes: least squares on the Vandermonde system y[k] = Σ c_i z_i^k.
let v = Array2::from_shape_fn((n, order), |(k, i)| poles[i].powi(k as i32));
let yc = Array1::from_shape_fn(n, |k| Complex::new(y[k], 0.0));
let amplitudes = v
.least_squares(&yc)
.map_err(|_| ErrorsJSL::RuntimeError("amplitude least squares failed"))?
.solution
.to_vec();
- The trigonometric interpolant computes its coefficients with a direct DFT, once; for long signals the FFT does the same in .
- Prony’s least-squares problems and the companion eigenvalues use
lib_jsl_linalg; the amplitudes are complex, and for real data they come in conjugate pairs, so the model’s real part is the fitted signal.
In practice
//! Trigonometric interpolation of periodic samples, and Prony's method for damped oscillations.
//!
//! Run with `cargo run -p lib_jsl_interpolation --example interpolation_fourier_prony`.
use lib_jsl_core::R1D;
use lib_jsl_interpolation::one_d::fourier_1d::FourierInterpolator1D;
use lib_jsl_interpolation::one_d::pronys_method::PronyModel;
use std::f64::consts::PI;
fn main() {
// A periodic signal sampled 24 times per period, evaluated between the samples.
let f = |x: f64| (2.0 * PI * x).sin().exp() + 0.3 * (6.0 * PI * x).cos();
let n = 24;
let samples = R1D::from_vec((0..n).map(|k| f(k as f64 / n as f64)).collect());
let interp = FourierInterpolator1D::new(samples.view(), 0.0, 1.0).unwrap();
let error = (0..1000).map(|i| { let x = i as f64 / 1000.0; (interp.evaluate(x) - f(x)).abs() }).fold(0.0, f64::max);
println!("trigonometric interpolation from {n} samples: max error {error:.1e}");
// A decaying chord: 220 Hz and 330 Hz with different damping, sampled at 2 kHz for 25 ms.
let dt = 1.0 / 2000.0;
let chord = |t: f64| (-40.0 * t).exp() * (2.0 * PI * 220.0 * t).sin() + 0.6 * (-90.0 * t).exp() * (2.0 * PI * 330.0 * t).cos();
let data = R1D::from_vec((0..50).map(|k| chord(k as f64 * dt)).collect());
let model = PronyModel::new(data.view(), 0.0, dt, 4).unwrap();
for s in model.exponents().into_iter().filter(|s| s.im > 0.0) {
println!("component: decay rate {:6.2} /s, frequency {:7.3} Hz", -s.re, s.im / (2.0 * PI));
}
println!("extrapolated to 40 ms: model {:.6}, true {:.6}", model.evaluate(0.04), chord(0.04));
}
Strengths
- Trigonometric interpolation: exponential accuracy for smooth periodic data, and exact frequency content.
- Prony: frequencies and damping rates from short records, beyond the Fourier resolution limit, and meaningful extrapolation.
Weaknesses
- Trigonometric interpolation of non-periodic data suffers Gibbs oscillations.
- Prony’s method is sensitive to noise and to the model order; overfitting the order helps, but the spurious components must be recognised (they are strongly damped) and discarded.
Exercises
- Show that the trigonometric interpolant of from samples is exact, and find what it becomes for (aliasing).
- Derive the linear recurrence satisfied by .
- Generate two undamped sinusoids at 100 Hz and 103 Hz, sampled at 1 kHz for 0.1 s, so that the Fourier resolution is 10 Hz. Can the DFT separate them? Can Prony’s method?
- Repeat the noisy fit with model orders 4 to 20 and plot the fitted damping rates. Which poles are stable as the order increases?
- Use a trigonometric interpolant of samples of (which is continuous but has a kink when extended periodically) and measure the convergence rate.
Hints and answers
- For the frequency is within the representable band and is reproduced exactly. For the samples are all equal, so the interpolant is the constant : frequency is an alias of frequency .
- , because are the roots of .
- The DFT cannot separate tones 3 Hz apart when its resolution is 10 Hz, and zero-padding only interpolates the same blurred spectrum. With noise-free data and the correct order (four complex exponentials for two real sinusoids), Prony’s method recovers both frequencies.
- Poles that stay at nearly the same frequency and damping as the order increases are the true ones; the spurious poles move about from one order to the next.
- The periodic extension of has a jump in its derivative, so the Fourier coefficients decay only like and the maximum error decreases algebraically, roughly like near the kink; plot the error on a log-log scale to measure the exponent.
Further reading
- G. R. de Prony, “Essai expérimental et analytique”, Journal de l’École Polytechnique 1 (1795) 24–76.
- M. T. Heideman, D. H. Johnson and C. S. Burrus, “Gauss and the history of the fast Fourier transform”, IEEE ASSP Magazine 1 (1984) 14–21.
- R. Kumaresan and D. W. Tufts, “Estimating the parameters of exponentially damped sinusoids and pole-zero modeling in noise”, IEEE Transactions on Acoustics, Speech, and Signal Processing 30 (1982) 833–840.
- S. M. Kay, Modern Spectral Estimation: Theory and Application, Prentice-Hall, 1988.
- L. N. Trefethen, Approximation Theory and Approximation Practice, SIAM, 2019, on trigonometric interpolation and its convergence.