Skip to main content

Section 25.1 Periodic functions and trigonometric polynomials

A function \(f\) is periodic if there exists a constant \(T\) such that \(f(x+T)=f(x)\) for all \(x\in \mathbb R\text{.}\) Examples include \(\sin x\text{,}\) \(\cos x\text{,}\) and their combinations called trigonometric polynomials:

\begin{equation} p(x)= \sum_{k=0}^n a_k \cos (2\pi kx/T) + \sum_{k=1}^n b_k \sin (2\pi kx/T) \label{eq-trigonometric-polynomial}\tag{25.1.1} \end{equation}

The function (25.1.1) has period \(T\text{.}\) Using Euler's identity

\begin{equation} e^{ix} = \cos x + i\sin x \label{eq-euler-identity}\tag{25.1.2} \end{equation}

one can express trigonometric polynomials in complex exponential form:

\begin{equation} p(x) = \sum_{k=-n}^n c_k \exp (2\pi i k x/T)\label{eq-trigonometric-polynomial-complex}\tag{25.1.3} \end{equation}

Indeed, the identity (25.1.2) implies \(\cos x = (e^{ix}+e^{-ix})/2\) and \(\sin x = (e^{ix}-e^{-ix})/(2i)\text{,}\) so the expression (25.1.1) can be rewritten as a linear combination of complex exponentials as in (25.1.3). Conversely, expression (25.1.3) can be rewritten in terms of trigonometric functions using (25.1.2).

It is important to recognize that even if the coefficients \(a_k, b_k\) were real, the corresponding coefficients \(c_k\) will in general be complex. Complex numbers in Matlab can be entered directly like 3 + 4i (note there is no * between 4 and i). If you have variables a, b and want to construct \(a + ib\text{,}\) then a + 1i*b works. Also, the letter j can be used in place of i.

The most common values of \(T\) are \(T=2\pi\) and \(T=1\text{.}\) Each choice makes some formulas simpler at the cost of making other formulas more complicated. This is why the theory of Fourier transform is presented in different sources with different notational conventions.

Plot a random trigonometric polynomial of degree 3, using complex exponential form with complex coefficients taken from the normal distribution. Note that Matlab command plot(z) when given a single vector z with complex values, interprets it as plot(real(z), imag(z)).

Answer

This example uses \(T=2\pi\) (the choice of period does not change these plots). Note the vectorized evaluation c*exp(1i*k'*t) and recognize the role of transpose k' here.

n = 3;
c = randn(1, 2*n+1)  + 1i*randn(1, 2*n+1);
t = linspace(0, 2*pi, 1000);
k = -n:n;
z = c*exp(1i*k'*t);
plot(z)