December 22, 2024

How to Express Sin and Cos Functions as the Sum and Difference of Complex Exponentials


In this mathematics, calculus, signal processing, and control engineering tutorial, we will learn how to express \sin and \cos functions of the real argument or of the real angles as the sum and difference of complex exponentials. That is, we will learn how to derive the following formulas

(1)   \begin{align*}\sin (\theta)=\frac{e^{j\theta}-e^{-j\theta}}{2j} \\\cos (\theta)=\frac{e^{j\theta}+e^{-j\theta}}{2} \end{align*}

where j is the imaginary unit and \theta is the angle that is often expressed in radians. These two formulas play a very important role in digital signal processing, control engineering, and in many other fields because many times they can be used to significantly simplify calculations of quantities such as transfer functions, magnitude and phase responses, etc. In this tutorial, we explain how to derive these formulas, and at the end of the tutorial, we explain how these formulas can be used to compute the coefficients of the Fourier series Expansion. The YouTube video accompanying this post is given below.

Derivation of Formulas

To derive these formulas we need to start from the Euler representation of the exponential of the complex number. Consider the complex unit circle shown in the figure below.

The complex number shown in the figure above can be represented in the polar form as

(2)   \begin{align*}|1|\cdot e^{j\theta}=e^{j\theta}\end{align*}

The complex number has projections onto the real and imaginary axes. These projections are 1\cdot \cos(\theta), and 1\cdot \sin(\theta), respectively. Consequently, we can represent the polar form as

(3)   \begin{align*}e^{j\theta}=\cos(\theta)+j\sin(\theta)\end{align*}

This is Euler’s formula for the exponential of the complex number. On the other hand, from (3), we have

(4)   \begin{align*}e^{-j\theta}=\cos(-\theta)+j\sin(-\theta)=\cos(\theta)-j\sin(\theta)\end{align*}

Let us write the formulas (3) and (4) together

(5)   \begin{align*}e^{j\theta}=\cos(\theta)+j\sin(\theta) \\e^{-j\theta}=\cos(\theta)-j\sin(\theta)\end{align*}

To derive the formulas for \sin (\theta) and \cos (\theta), we can think of these two equations as two equations with two unknowns that we want to solve. The unknowns are \sin (\theta) and \cos (\theta).

Let us first solve these two equations for \sin (\theta). From (5), we have

(6)   \begin{align*}e^{j\theta}-e^{-j\theta}=\cos(\theta)+j\sin(\theta)-\cos(\theta)+j\sin(\theta)=2j\sin(\theta)\end{align*}

From the last equation, we obtain the expression for \sin (\theta)

(7)   \begin{align*}\sin(\theta)=\frac{e^{j\theta}-e^{-j\theta}}{2j}\end{align*}

Next, let us solve the equations (5) for \cos (\theta). From this equation, we have

(8)   \begin{align*}e^{j\theta}+e^{-j\theta}=\cos(\theta)+j\sin(\theta)+\cos(\theta)-j\sin(\theta)=2\cos(\theta)\end{align*}

From the last equation, we obtain the expression for \cos (\theta)

(9)   \begin{align*}\cos(\theta)=\frac{e^{j\theta}+e^{-j\theta}}{2}\end{align*}

Application of Derived Formulas

We use the derived formulas to solve the following problem. Compute the Fourier series coefficients and Fourier series expansion of the following periodic function

(10)   \begin{align*}y(t)=\cos (2\omega_{0}t)+\sin (3\omega_{0}t)\end{align*}

where \omega_{0} is the fundamental frequency. We can solve this problem by using the Fourier series integrals that we explained in our previous tutorial. However, there is a more elegant approach to solving this problem by using the formulas (1). By using these formulas, we obtain

(11)   \begin{align*}y(t)=\frac{e^{j2\omega_{0}t}+e^{-j2\omega_{0}t}}{2}+ \frac{e^{j3\omega_{0}t}-e^{-j3\omega_{0}t}}{2j}\end{align*}

From this expression, we immediately obtain the Fourier series expansion

(12)   \begin{align*}y(t)=-\frac{1}{2j}e^{-j3\omega_{0}t}+\frac{1}{2}e^{-j2\omega_{0}t}+\frac{1}{2}e^{j2\omega_{0}t}+\frac{1}{2j}e^{j3\omega_{0}t}\end{align*}

That is

(13)   \begin{align*}y(t)=c_{-3}e^{-j3\omega_{0}t}+c_{-2}e^{-j2\omega_{0}t}+c_{2}e^{j2\omega_{0}t}+c_{3}e^{j3\omega_{0}t}\end{align*}

where the Fourier series coefficients are given below

(14)   \begin{align*}c_{-3}=-\frac{1}{2j} \\c_{-2}=\frac{1}{2}\\c_{2}=\frac{1}{2}\\c_{3}=\frac{1}{2j}\end{align*}