Trigonometric interpolation

In mathematics, trigonometric interpolation is interpolation with trigonometric polynomials. Interpolation is the process of finding a function which goes through some given data points. For trigonometric interpolation, this function has to be a trigonometric polynomial, that is, a sum of sines and cosines of given periods. This form is especially suited for interpolation of periodic functions.

An important special case is when the given data points are equally spaced, in which case the solution is given by the discrete Fourier transform.

Formulation of the interpolation problem
A trigonometric polynomial of degree K has the form

This expression contains 2K + 1 coefficients, a0, a1, … aK, b1, …, bK, and we wish to compute those coefficients so that the function passes through N points:
 * $$ p(x_n) = y_n, \quad n=0, \ldots, N-1. \, $$

Since the trigonometric polynomial is periodic with period 2π, the N points can be distributed and ordered in one period as
 * $$ 0 \leq x_0 < x_1 < x_2 < \ldots < x_{N-1} < 2  \pi. \, $$

(Note that we do not in general require these points to be equally spaced.) The interpolation problem is now to find coefficients such that the trigonometric polynomial p satisfies the interpolation conditions.

Formulation in the complex plane
The problem becomes more natural if we formulate it in the complex plane. We can rewrite the formula for a trigonometric polynomial as $$ p(x) = \sum_{k=-K}^K c_k e^{ikx}, \, $$ where i is the imaginary unit. If we set z = eix, then this becomes
 * $$ q(z) = \sum_{k=-K}^K c_k z^{k}, \, $$

with
 * $$ q(e^{ix}) \triangleq p(x). \, $$

This reduces the problem of trigonometric interpolation to that of polynomial interpolation on the unit circle. Existence and uniqueness for trigonometric interpolation now follows immediately from the corresponding results for polynomial interpolation.

For more information on formulation of trigonometric interpolating polynomials in the complex plane, see p. 156 of Interpolation using Fourier Polynomials.

Solution of the problem
Under the above conditions, there exists a solution to the problem for any given set of data points {xk, yk} as long as N, the number of data points, is not larger than the number of coefficients in the polynomial, i.e., N ≤ 2K+1 (a solution may or may not exist if N>2K+1 depending upon the particular set of data points). Moreover, the interpolating polynomial is unique if and only if the number of adjustable coefficients is equal to the number of data points, i.e., N = 2K + 1. In the remainder of this article, we will assume this condition to hold true.

Odd number of points
If the number of points N is odd, say N=2K+1, applying the Lagrange formula for polynomial interpolation to the polynomial formulation in the complex plane yields that the solution can be written in the form

where
 * $$ t_k(x) = e^{-iKx+iKx_k} \prod_{\begin{align}m&=0 \\[-4mu] m &\ne k\end{align}}^{2K} \frac{e^{ix}-e^{ix_m}}{e^{ix_k}-e^{ix_m}}.$$

The factor $$e^{-iKx+iKx_k}$$ in this formula compensates for the fact that the complex plane formulation contains also negative powers of $$e^{ix}$$ and is therefore not a polynomial expression in $$e^{ix}$$. The correctness of this expression can easily be verified by observing that $$t_k(x_k)=1$$ and that $$t_k(x)$$ is a linear combination of the right powers of $$e^{ix}$$. Upon using the identity

the coefficient $$t_k(x)$$ can be written in the form

Even number of points
If the number of points N is even, say N=2K, applying the Lagrange formula for polynomial interpolation to the polynomial formulation in the complex plane yields that the solution can be written in the form

where

Here, the constants $$\alpha_k$$ can be chosen freely. This is caused by the fact that the interpolating function ($$) contains an odd number of unknown constants. A common choice is to require that the highest frequency is of the form a constant times $$\cos(Kx)$$, i.e. the $$\sin(Kx)$$ term vanishes, but in general the phase of the highest frequency can be chosen to be $$\varphi_K$$. To get an expression for $$\alpha_k$$, we obtain by using ($$) that ($$) can be written on the form
 * $$ t_k(x) = \frac{\cos\tfrac12\Biggl(2Kx-\alpha_k+\displaystyle\sum\limits_{m=0,\,m \ne k}^{2K-1} x_m\Biggr)+\sum\limits_{m=-(K-1)}^{K-1}c_k e^{imx}}{2^N\sin\tfrac12(x_k-\alpha_k)\displaystyle\prod\limits_{m=0,\,m \ne k}^{2K-1}\sin\tfrac12(x_k-x_m)}.$$

This yields
 * $$\alpha_k=\sum_{\begin{align}m&=0 \\[-4mu] m &\ne k\end{align}}^{2K-1} x_m - 2 \varphi_K$$

and
 * $$ t_k(x) = \frac{\sin\tfrac12(x-\alpha_k)}{\sin\tfrac12(x_k-\alpha_k)}\prod_{\begin{align}m&=0 \\[-4mu] m &\ne k\end{align}}^{2K-1} \frac{\sin\tfrac12(x-x_m)}{\sin\tfrac12(x_k-x_m)}.$$

Note that care must be taken in order to avoid infinities caused by zeros in the denominators.

Equidistant nodes
Further simplification of the problem is possible if nodes $$x_m$$ are equidistant, i.e.
 * $$x_m=\frac{2\pi m}{N},$$

see Zygmund for more details.

Odd number of points
Further simplification by using ($$) would be an obvious approach, but is obviously involved. A much simpler approach is to consider the Dirichlet kernel
 * $$D(x,N)=\frac{1}{N} +\frac{2}{N} \sum_{k=1}^{(N-1)/2}\cos(kx) = \frac{\sin\tfrac12 Nx}{N\sin\tfrac12 x},$$

where $$N>0$$ is odd. It can easily be seen that $$D(x,N)$$ is a linear combination of the right powers of $$e^{ix}$$ and satisfies
 * $$D(x_m,N)=\begin{cases}0\text{ for } m\neq0 \\1\text{ for } m=0\end{cases}.$$

Since these two properties uniquely define the coefficients $$t_k(x)$$ in ($$), it follows that
 * $$\begin{align}

t_k(x) &= D(x-x_k,N)=\begin{cases} \dfrac{\sin\tfrac12 N(x-x_k)}{N\sin\tfrac12 (x-x_k)} \text{ for } x\neq x_k\\[10mu] \lim\limits_{x\to 0} \dfrac{\sin\tfrac12 Nx}{N\sin\tfrac12 x}=1 \text{ for } x= x_k \end{cases}\\&= \frac{\mathrm{sinc}\,\tfrac12 N(x-x_k)}{\mathrm{sinc}\,\tfrac12 (x-x_k)}. \end{align}$$ Here, the sinc-function prevents any singularities and is defined by
 * $$ \mathrm{sinc}\,x=\frac{\sin x}{x}.$$

Even number of points
For $$N$$ even, we define the Dirichlet kernel as
 * $$D(x,N)=\frac{1}{N} +\frac{1}{N}\cos \tfrac12 Nx + \frac{2}{N} \sum_{k=1}^{(N-1)/2}\cos(kx) = \frac{\sin\tfrac12 Nx}{N\tan\tfrac12 x}.$$

Again, it can easily be seen that $$D(x,N)$$ is a linear combination of the right powers of $$e^{ix}$$, does not contain the term $$ \sin \tfrac12 Nx $$ and satisfies
 * $$D(x_m,N)=\begin{cases}0\text{ for } m\neq0 \\1\text{ for } m=0\end{cases}.$$

Using these properties, it follows that the coefficients $$t_k(x)$$ in ($$) are given by
 * $$\begin{align}

t_k(x) &= D(x-x_k,N)=\begin{cases} \dfrac{\sin\tfrac12 N(x-x_k)}{N\tan\tfrac12 (x-x_k)}\text{ for } x\neq x_k\\[10mu] \lim\limits_{x\to 0} \dfrac{\sin\tfrac12 Nx}{N\tan\tfrac12 x}=1 \text{ for } x= x_k. \end{cases}\\&= \frac{\mathrm{sinc}\,\tfrac12 N(x-x_k)}{ \mathrm{sinc}\,\tfrac12 (x-x_k)}\cos\tfrac12 (x-x_k) \end{align}$$ Note that $$t_k(x)$$ does not contain the $$ \sin \tfrac12 Nx $$ as well. Finally, note that the function $$ \sin \tfrac12 Nx $$ vanishes at all the points $$x_m$$. Multiples of this term can, therefore, always be added, but it is commonly left out.

Implementation
A MATLAB implementation of the above can be found here and is given by:

Relation with the discrete Fourier transform
The special case in which the points xn are equally spaced is especially important. In this case, we have
 * $$ x_n = 2 \pi \frac{n}{N}, \qquad 0 \leq n < N.$$

The transformation that maps the data points yn to the coefficients ak, bk is obtained from the discrete Fourier transform (DFT) of order N.


 * $$ Y_k = \sum_{n=0}^{N-1} y_n \ e^{-i 2 \pi nk/N} \, $$


 * $$ y_n = p(x_n) = \frac{1}{N} \sum_{k=0}^{N-1} Y_k \ e^{i 2 \pi nk/N} \, $$

(Because of the way the problem was formulated above, we have restricted ourselves to odd numbers of points. This is not strictly necessary; for even numbers of points, one includes another cosine term corresponding to the Nyquist frequency.)

The case of the cosine-only interpolation for equally spaced points, corresponding to a trigonometric interpolation when the points have even symmetry, was treated by Alexis Clairaut in 1754. In this case the solution is equivalent to a discrete cosine transform. The sine-only expansion for equally spaced points, corresponding to odd symmetry, was solved by Joseph Louis Lagrange in 1762, for which the solution is a discrete sine transform. The full cosine and sine interpolating polynomial, which gives rise to the DFT, was solved by Carl Friedrich Gauss in unpublished work around 1805, at which point he also derived a fast Fourier transform algorithm to evaluate it rapidly. Clairaut, Lagrange, and Gauss were all concerned with studying the problem of inferring the orbit of planets, asteroids, etc., from a finite set of observation points; since the orbits are periodic, a trigonometric interpolation was a natural choice. See also Heideman et al. (1984).

Applications in numerical computing
Chebfun, a fully integrated software system written in MATLAB for computing with functions, uses trigonometric interpolation and Fourier expansions for computing with periodic functions. Many algorithms related to trigonometric interpolation are readily available in Chebfun; several examples are available here.