Introduction to Signals

The Concept of Frequency

A complex sinusoid V rotating in time IQ-plane and generating two real sinusoids

Wireless signals between two devices travel through the use of radio waves. A radio wave is an electromagnetic wave propagated by an antenna. Radio waves have different frequencies, and one can pick up a specific signal by tuning a radio receiver to a specific frequency. But what is a frequency anyway?

A Complex Sinusoid

Consider a complex number V in an IQ-plane with an angle \theta and length A as shown in this Figure. Its projection on I-axis is equal to A \cos\theta and projection on Q-axis is equal to A \sin\theta. Now imagine V rotating with an angle continuously increasing with time. Then, V can be treated as a signal with time as independent variable and we call it a complex sinusoid. Just like velocity is the rate of change of displacement, frequency is the rate of change in phase of a complex sinusoid. This rate of change of phase results in V rotating in the time IQ-plane at an angular velocity 2\pi F, as shown in Figure below.

A complex sinusoid V rotating in time IQ-plane and generating two real sinusoids

Note that as time passes, V is shown in Figure above as coming out of the page. When its projection from a 3-dimensional plane to a 2-dimensional plane formed by time and I-axis is drawn, we get A \cos (2\pi F t + \theta). Similarly, when the projection is drawn on a 2-dimensional plane formed by time and Q-axis, it generates A \sin (2\pi F t + \theta). Randomly choosing \cos(\cdot) as our reference sinusoid, the I component is called inphase because it is in phase with \cos(\cdot) while Q component is called qaudrature because \sin(\cdot) is in quadrature — i.e.,90^ \circ apart — with \cos(\cdot).

In conclusion, a complex sinusoid with frequency F is composed of two real sinusoids

(1)   \begin{align*}             V_I\: &= A\cos(2\pi F t  + \theta) \\             V_Q   &= A\sin(2\pi F t + \theta)         \end{align*}

where F is the continuous frequency with units of cycles/second or Hertz (Hz). The direction of rotation is considered positive for anticlockwise rotation, and negative for clockwise rotation.

Amplitude A and phase \theta are the two other parameters that characterize a sinusoidal signal, where A determines the maximum amplitude for the sinusoid, and \theta determines the initial angular offset of V at t=0.

Sinusoid parameters

Remember that whenever you hear the word “frequency”, it is the frequency of a sinusoid A\cos(2 \pi F t  + \theta) or A\sin(2 \pi F t  + \theta). There are 3 parameters that characterize a sinusoid:

  1. Frequency \rightarrow F
  2. Phase \rightarrow \theta
  3. Amplitude \rightarrow A

Referring to this Figure, it is clear that if the complex sinusoid V rotates faster, the corresponding real sinusoids jump up and down faster, the time T for completing one period becomes smaller, and we call it a higher frequency. Therefore, it is related to time period T as

    \begin{align*}     F = \frac{1}{T}     \end{align*}

and the range of continuous frequency values is

    \begin{equation*}      -\infty < F < \infty     \end{equation*}


When one tunes to a radio station at 88 MHz, one is actually listening to a station broadcasting a radio signal at a carrier frequency of 88\times10^6 Hz, which means that the transmitter is oscillating at a frequency of 88,000,000 cycles/second. Accordingly, that wave is completing one period in T = 1/F = 11.4 ns.

What is a Negative Frequency?

Negative frequencies can cause some confusion as it is hard to visualize a negative frequency viewed as inverse period of a sinusoid. Since the term magnitude is absolute value of the amplitude, the inverse period only gives the magnitude of that frequency. Define it through the rate of rotation of a complex sinusoid V in this Figure, and it is evident that a negative frequency simply implies rotation of V in a clockwise direction. Negative frequencies are real, just like negative numbers are real.

A Real Sinusoid

We have learned that a complex sinusoid rotating in time IQ-plane generates two real sinusoids. The question is: How to produce only one real sinusoid in complex plane?

Interestingly, just like a complex sinusoid is made up of two real sinusoids (Eq (1)), a real sinusoid can be produced by two complex sinusoids rotating in opposite directions to each other, one with a positive frequency F and other with a negative frequency -F. From Figure below, it can be seen that Q components of the complex sinusoids cancel out in this scenario while I parts add up to form a cosine wave. As before, time dimension, not shown here, is coming out of the page.

Two complex sinusoids rotating in opposite directions in time IQ-plane and generating one real sinusoid

From the definitions of a complex sinusoid V in Eq (1) and conjugate of a complex number in this Eq, a real cosine wave can be written as

    \begin{align*}         V_I &= \frac{1}{2}(V + V^*)     \end{align*}

The amplitudes of both complex sinusoids are scaled by 1/2 to cater for factor 2 from addition of two similar I parts. A sine wave can also be constructed in a similar manner.

Frequency Domain

Above, we have talked about frequency being the rate of rotation of a complex sinusoid in time IQ-plane (as in this Figure). It is evident that this rate of rotation can be changed from very slow (close to 0) to as fast as possible (close to +\infty). As also explained above, a clockwise direction of rotation implies a negative frequency, and hence the complete range of frequencies of a complex sinusoid is from -\infty to +\infty. When a signal or function is drawn in frequency domain, the graph actually shows the I and Q components of those complex sinusoids whose frequencies are present in that signal.

Since one complex sinusoid has a single frequency, it is drawn as a narrow impulse on the frequency IQ-plane. Remember that this frequency IQ-plane is different than the time IQ-plane drawn in this Figure earlier.

Let us look at examples of a real cosine wave and a real sine wave in frequency domain representation in Figure below.

A sine and cosine in both time and frequency IQ-planes

Time IQ-plane vs Freq IQ-plane

The arrows in frequency IQ-plane are not rotating like this Figure and this Figure earlier. In fact, these are frequency domain impulse symbols indicating a single spectral line for a single complex sinusoid. The height of the impulses in frequency domain indicates the magnitude of that sinusoid while their relative phases can be seen through the directions in which the spectral impulses are pointing.

Any signal plotted in frequency domain represents the magnitudes and phases of complex sinusoids combined together to form that signal. As such, they form a basic unit of signal construction of any shape. As more and more such sinusoids come together, they form a continuum in frequency domain that is illustrated as a continuous spectral graph.

A natural question arises at this stage: What about the signals having components other than these nice looking sinusoids? The answer is surprising: There are hardly any! Long ago, scientists figured out that most signals of practical interest can be considered as a sum of many sinusoids — possibly infinite — oscillating at different frequencies regardless of the signal shape. So an arbitrary signal s(t) can be written as

    \begin{align*}   s(t) &= a_0 \sin (2\pi F_0 t) + a_1 \sin (2\pi F_1 t) + a_2 \sin (2\pi F_2 t) + \cdots \\        &= a_0 \sin (2\pi\frac{1}{T_0} t) + a_1 \sin (2\pi\frac{1}{T_1} t) + a_2 \sin (2\pi \frac{1}{T_2} t) + \cdots \end{align*}

where a_0, a_1,a_2,\cdots, are amplitudes that determine the impact each sinusoid has on s(t). If s(t) has no sinusoid of frequency F_k, then the corresponding amplitude a_k = 0.

It is difficult to believe in such a statement for many signals with sharp edges like a square or triangular waveform but this concept is true even for such signals. In that case, the number of sinusoids participating in construction of that signal tends to \infty.

As an example, consider a square wave signal. The curves in Figure below show how it is approximated with integer multiples of a fundamental frequency F = 1/T (the corresponding negative axis in frequency domain is not shown for simplicity).

Time and frequency representations of a square wave signal

The blue curve consists of the first two terms

    \begin{align*}       s(t) &= \sin(2 \pi F t) + \frac{1}{3}\sin( 2 \pi 3F t) \\            &= \sin \left(2 \pi\frac{1}{T} t \right) + \frac{1}{3}\sin \left(2 \pi\frac{3}{T} t \right)     \end{align*}

which is clearly quite inaccurate. However, increasing this approximation with just three more terms in red curve as

    \begin{align*}       s(t) &= \sin(2 \pi F t) + \frac{1}{3}\sin(2 \pi 3F t) + \frac{1}{5}\sin(2 \pi 5F t) + \\            & \hspace{2.6in} \frac{1}{7}\sin(2 \pi 7F  t) + \frac{1}{9}\sin( 2 \pi 9F t) \\            &= \sin \left(2 \pi\frac{1}{T} t \right) + \frac{1}{3}\sin \left(2 \pi\frac{3}{T} t \right) + \frac{1}{5}\sin \left(2 \pi\frac{5}{T} t \right) + \\            & \hspace{3in} \frac{1}{7}\sin \left(2 \pi\frac{7}{T} t \right) + \frac{1}{9}\sin \left(2 \pi\frac{9}{T} t \right)     \end{align*}

displays significantly closer behaviour. If we increase the number of sinusoids with respective decreasing amplitudes, we can improve this approximation even more.

Spectrum and Bandwidth

A frequency spectrum, or simply the spectrum, is just the range of all possible frequencies of electromagnetic radiation. A full continuous spectrum, for example, includes radio waves, microwaves, infrared, ultraviolet, x-rays and gamma rays.

In an ideal world, bandwidth of a signal is the range of frequencies of sinusoids present in that signal. In other words, taking into account all the sinusoids, the bandwidth is simply the difference between the highest frequency F_H and the lowest frequency F_L in the spectrum of that signal.

    \begin{equation*}       \textmd{BW} = F_H - F_L     \end{equation*}

An ideal band-limited signal has a spectrum that is zero outside a finite frequency range F_L \le |F| \le F_H:

    \begin{equation*}     S(F) = \left\{ \begin{array}{l}     0, \quad 0 \le |F| \le F_L \\     ?, \quad |F_L| \le |F| \le |F_H| \\     0, \quad F_H \le |F| \le \infty \\     \end{array} \right.     \end{equation*}

Having said that, a signal can have a very low contribution from a sinusoid of a particular frequency but not completely zero. Skipping the mathematical proof, we present the following argument: Remember that the concept of frequency is defined through sinusoids that are infinitely long in time domain, see this Figure. Since sinusoids exist only for a finite duration in real-world, the spectrum of these truncated sinusoids is not an impulse as shown in this Figure. Instead, frequency domain representation of a finite duration sinusoid spreads out in the entire spectrum from -\infty to +\infty.

Time and frequency support

A signal cannot be limited in both time and frequency domains. For practical implementations, a signal must be time limited which makes it unlimited in frequency. Therefore, every real signal occupies an infinite amount of bandwidth. A band-limited signal is then referred to as a signal with most of its energy concentrated within a certain amount of frequency range. Practical definitions of bandwidth vary depending on that amount of energy.

For example, Federal Communications Commission (FCC) defines bandwidth as the band in which 99 \% of the signal power is contained. Another common definition is that everywhere outside the specified band, a certain attenuation (say, 60 dB) must be attained.

As a general rule, signals with fast irregular variations have large bandwidth as a large number of sinusoids are required to build such a signal, while slowly varying signals have low bandwidth. Consequently, signals that are narrow in time domain have a large bandwidth in frequency domain, and vice versa.

Some Signal Classifications

Plot of a quadratic signal with time

Some signals have specific properties which makes computations simpler. For example,

Even and Odd

A signal is called even (or symmetric) if

    \begin{equation*}     s[-n] = s[n] \end{equation*}

Flipping an even signal around amplitude axis results in the same signal. Examples of even signals are s[n] = \cos[2\pi f_0 n] and a quadratic signal s[n] = n^2 (see e.g., this Figure).

On the other hand, a signal is called odd (or anti-symmetric) if

    \begin{equation*}     s[-n] = -s[n] \end{equation*}

An odd signal has symmetry around the origin. Examples of an odd signal are s[n] = \sin[2\pi f_0 n] and s[n] = -n.

Periodic and Aperiodic

A signal is periodic if it repeats itself after a certain period N.

    \begin{equation*}     s[n\pm N] = s[n] \quad \textmd{for all} ~n \end{equation*}

Both s[n] = \cos[2\pi f_0 n] and s[n] = \sin[2\pi f_0 n] are examples of periodic signals if f_0 is a rational number.

If a signal does not repeat itself forever, there is no value of N that satisfies the above periodicity equation. Such a signal is known as aperiodic, an example of which is a unit step signal u[n] and most other signals encountered in this text.

Discrete Frequency

Discrete frequency axis obtained by sampling the continuous frequency axis

We have talked about the concept of frequency and sampling a continuous-time signal to generate a discrete-time signal. Remember that the reason we work with discrete-time signals is that finite computer memory can store only a fixed number of time values. Similarly, this finite memory can also store only a fixed number of frequency values instead of infinite range of F.

For this reason, while we are at sampling in time domain, we also want to sample the frequency domain. Assume that a total of N samples were collected in time domain (see this Figure) at a rate of F_S = 1/T_S, thus spanning a time duration of NT_S seconds. Then, the lowest frequency that can be represented by these N samples is the one by a signal that completes one full cycle — and no more — during this interval of NT_S seconds and consequently given by 1/(NT_S) Hz. Consider the equation

    \begin{align*}         \frac{1}{NT_S} &= \frac{F_S}{N} \\                        &= F_S\cdot \frac{1}{N}     \end{align*}

and observe that

  • Frequency resolution, determined by the lowest frequency that can be represented, is given by F_S/N.
  • Viewed as F_S \cdot 1/N, we can get N discrete frequency samples that are integer multiples of 1/N, if we want the same number N of frequency samples as the time domain samples.

As explained in the article on sampling, the unique range of continuous frequency F is -0.5F_S \le F < +0.5F_S, or

    \begin{equation*}     -0.5 \le \frac{F}{F_S} < +0.5      \end{equation*}

called the primary zone. To obtain the discrete frequency axis, -0.5 \le F/F_S < +0.5 is divided into N equal intervals (assuming N is even) by sampling at instants

(1)   \begin{align*}          -0.5,-0.5+\frac{1}{N},\cdots,-\frac{1}{N},0,\frac{1}{N},\cdots,+0.5-\frac{1}{N}      \end{align*}

resulting in a discrete frequency resolution of 1/N. So discrete frequency is basically the spectral content in the primary zone sampled at N equally spaced frequency points. The term +0.5 is absent because it is the same as -0.5 owing to the axis periodicity.

Eq (1) can also be written as

(2)   \begin{align*}         \frac{-N/2}{N}, \frac{-N/2+1}{N}, \cdots, -\frac{1}{N},0,\frac{1}{N},\cdots, \frac{N/2-1}{N}      \end{align*}

Consequently, the index k of discrete frequency axis shown in Figure below is given by [-N/2,N/2-1], or

(3)   \begin{align*}         k = -\frac{N}{2},-\frac{N}{2}+1,\cdots,-1,0,1,\cdots,\frac{N}{2}-1      \end{align*}

Discrete frequency axis obtained by sampling the continuous frequency axis

Comparing Eq (1) and Eq (2), we arrive at the relation between discrete frequency k/N and continuous frequency F as

(4)   \begin{equation*}       \frac{k}{N} = \frac{F}{F_S}     \end{equation*}

From the above equation, the actual continuous frequency represented by discrete frequency index k depends on both the sample rate F_S and N as

    \begin{equation*}     F = F_S \cdot \frac{k}{N}     \end{equation*}

For example, with F_S = 3 kHz and N = 32,

    \begin{align*}     k = 0 \quad \rightarrow \quad F &= 3000 \cdot \frac{0}{32} = 0 ~\textmd{Hz} \\     k = 1 \quad \rightarrow \quad F &= 3000 \cdot \frac{1}{32} = 93.75 ~\textmd{Hz} \\     k = 2 \quad \rightarrow \quad F &= 3000 \cdot \frac{2}{32} = 187.5 ~\textmd{Hz}     \end{align*}

Each k is therefore called a frequency bin and the value N determines the number of input samples and the resolution of discrete frequency domain. Understanding the sampling theorem and the relationship between continuous and discrete frequencies will make the further concepts much easier to grasp.

The units of discrete frequency k/N from Eq (4) are

    \begin{align*}     \frac{\textmd{cycles}}{\textmd{second}} \div \frac{\textmd{samples}}{\textmd{second}} = \frac{\textmd{cycles}}{\textmd{sample}}     \end{align*}

Discrete frequency axis

Eq (4) is one of the two most fundamental relations in digital signal processing, the other being the sampling theorem. These are the two interfaces between continuous and discrete worlds.

Establishing the relationship between continuous and discrete frequencies gives the frequency domain as a sequence of numbers stored in a processor memory.

When in doubt about continuous and discrete frequency domains, refer to Eq (4)!

Having known the discrete frequency axis, it is natural to ask how these discrete frequencies physically look like. Of course, these are frequencies of a set of complex sinusoids with both I and Q components, as defined in a previous post about complex sinusoids and shown in Figure below for N = 8.

8 complex sinusoids of a discrete frequency axis

Following are a few key observations in this figure.

  • For k = 0, the I sinusoid is 1 because \cos 0 = 1, while Q sinusoid is 0 because \sin 0 = 0. Of course in a time IQ-plane, this means a point standing still at (1,0).
  • The I and Q waveforms for k = 1 are \cos 2\pi\cdot1/N and \sin 2\pi\cdot1/N and they complete on full cycle during N = 8 samples. This is true in general. Here for a sample rate of F_S = 8 kHz, it resulted in F = F_S \cdot 1/N = 8 \cdot 1/8 = 1 kHz with a time period equal to 1/F = 1 ms. One full cycle ensues because N = 8 samples at F_S = 8 kHz span a time duration of 1 ms as well. Similarly, each complex sinusoid for each k span k complete cycles in an interval of N samples.
  • For negative values of k, I sinusoids remain unchanged while Q sinusoids change sign. This can be observed from the definition of a complex sinusoid rotating in an IQ-plane as shown in this Figure and this Figure. I part is same for both positive and negative directions of rotations, whereas Q part is positive for positive direction and negative for negative direction.

In conclusion, the range of unique discrete frequencies k/N is

(5)   \begin{equation*}      \tcbhighmath{-0.5 \le \frac{k}{N} < +0.5}     \end{equation*}

From the above discussion, the rate of oscillation in discrete-time signals decreases with k/N going from -0.5 to 0 and increases from 0 to +0.5, remembering that k/N = -0.5 is the same as k/N = +0.5.


Consider a signal

    \begin{equation*}         s(t) = 2 \cos(2 \pi 1000 t) + 7 \sin(2\pi 3000 t) + 3 \cos(2 \pi 6000t)     \end{equation*}

It is clear that continuous frequencies present in this signal are F_1 = 1 kHz, F_2 = 3 kHz and F_3 = 6 kHz. Since the maximum frequency is 6 kHz, the sampling theorem gives the Nyquist rate as 2\times6 kHz = 12 kHz.

Now suppose that this signal is sampled at F_S = 5 kHz, the folding frequency is then given by 0.5F_S = 2.5 kHz. Sampling the signal at equal intervals of t = nT_S

    \begin{align*}         s[n] &= s(t)|_{t = nT_S} = s\left(\frac{n}{F_S}\right) \\              &= 2 \cos 2 \pi \frac{1}{5} n + 7 \sin 2 \pi \frac{3}{5}n + 3 \cos 2 \pi \frac{6}{5}n \\              &= 2 \cos 2 \pi \frac{1}{5} n + 7 \sin 2 \pi \left(1 - \frac{2}{5}\right)n + 3 \cos 2 \pi \left(1+\frac{1}{5}\right)n \\              &= 2 \cos 2 \pi \frac{1}{5} n + 7 \sin 2 \pi \left(-\frac{2}{5}\right)n + 3 \cos 2 \pi\left(\frac{1}{5}\right)n \\              &= 5 \cos 2 \pi \frac{1}{5} n - 7 \sin 2 \pi \frac{2}{5}n     \end{align*}

If this signal is reconstructed in continuous-time domain, the frequencies present are k/N = 1/5 and k/N = -2/5. From Eq (4), these appear as continuous frequencies at F_1 = 5\times1/5=1 kHz and 5\times-2/5 = -2 kHz. Since only 1 kHz is less than 0.5F_S and hence within aliasing-free range, it is still there after sampling. The other two are above the folding frequency and hence aliased to F_2-F_S = 3-5=-2 kHz and F_3-F_S=6-5=1 kHz.

In these articles, every time we write the expression involving a discrete frequency, we express it either as 2\pi \frac{k}{N}n or 2\pi (k/N)n, instead of 2\pi kn/N that is used in most texts. The former clearly indicates the presence of a sampled discrete frequency k/N analogous to the variable F in 2\pi Ft, while it is easy to lose this meaning in the latter (the expression 2\pi kn/N more closely resembles a Fourier series description, which we keep out to keep the explanations simple). In addition, dealing with complex numbers through an IQ notation not only describes how they are implemented in actual electronic circuits, but it also constantly reminds us how phase is equally important in signal analysis. It is easy to overlook this fact in other more commonly used notations.

Transforming a Signal

A signal plot with its present, now and future

Transforming a discrete-time signal — whether in time or amplitude — is certainly possible, and often in interesting ways. In practice, scaling and time shifting are the two most important signal modifications encountered. Scaling changes the values of dependent variable on amplitude-axis while time shifting affects the values of independent variable on time-axis.

Below we describe addition and multiplication of two signals as well as scaling and time shifting a signal in detail.


For addition of two discrete-time signals, say x[n] and y[n], add the two signals sample-by-sample: z[n] = x[n] + y[n] for every n, e.g.,

    \begin{align*} z[0] &= x[0] + y[0] \\ z[1] &= x[1] + y[1] \\ \cdots & \cdot\cdot \end{align*}

and so on.


For multiplication, multiply the two signals sample-by-sample, as we did with addition: x[n] \cdot y[n] for every n, e.g.,

    \begin{align*} z[0] &= x[0] \cdot y[0]\\ z[1] &= x[1] \cdot y[1]\\ \cdots & \cdot\cdot \end{align*}

and so on.


Scaling implies multiplying the signal amplitude by a constant number \alpha resulting in \alpha~s[n], where \alpha can be positive, negative, greater than or lower than 1. For example, Figure below shows a signal s[n] scaled by 4 (compare the amplitudes of both signals on y-axis). One word of caution: The whole signal gets scaled by the same value here and hence scaling is different than sample-by-sample multiplication of two signals.

A signal and its 4x scaled version

Time Shifting

A signal s[n] can be shifted to the right or left by any amount m. There are two ways to look at time shifting a signal.

Conventional Method – Shifting the Signal

Most textbooks on discrete-time signals describe this process as follows.

[Delay] For s[n-m], the time shift results in a delay of s[n] by m units of time. So plot s[n-2] by shifting s[n] two units to the right as shown in Figure below.

[Advance] For s[n+m], the time shift results in an advance of s[n] by m units of time. So plot s[n+2] by shifting s[n] two units to the left as shown in Figure below.

A signal is shown with its left and right shifted versions

This is simple to remember: Write the time shift as n-m. Shift right for s[n-m] and shift left for s[n+m].

There are two problems with the approach above.

  1. It does not explain why we are doing what we are doing.
  2. A confusion might arise in the following way. The past samples of the sequence are to the left of the origin while the future samples are to the right. When we advance a signal by shifting left, a beginner might think that the future samples are on the left side. A similar argument holds for delaying a signal.

Intuitive Method – Shifting the Axis

This method is based on the earliest notions of time kept by humans: past, present and future. Replacing the word present with the NOW, consider the following quote:

"Realize deeply that the present moment is all you have. Make the NOW the primary focus of your life."

Eckhart Tolle – The Power of Now

In signal processing applications, NOW is the time index 0 and we want to make it the primary focus of a signal’s life, as shown in Figure below.

A signal plot with its present, now and future

Looking from this perspective,
[Delay] For s[n-m], n-m clearly implies traveling m units in the past. So plot s[n-2] by going 2 units back in time and making it the new NOW, i.e., time index 0 as shown in Figure below.
[Advance] For s[n+m], n+k obviously implies a future travel of m units. So plot s[n+2] by going 2 units towards the future and making it the new NOW, i.e., time index 0 as shown in Figure below.

A signal is shown with its axis shifted versions

Stated in another way, just look at the time-axis itself. Keep the discrete-time signal as it is, but move 0 time index m units to the left for n-m and m units to the right for n+m, as in Figure above. Notice that index 0 of s[n+2] is at the same sample as index 2 of s[n], which indicates accessing a future value. Although the difference is only how to look at the process, this is a simpler and more intuitive approach. This will be very helpful when we will discuss the topic of convolution later.

Note that as far as drawing time shifted signals is concerned, we will mostly use the first approach because it saves page space by aligning the time-axis indices right on top of one another.

Addition of time shifted signals

Understanding time shifting a signal makes it easy to analyze seemingly complicated equations such as

    \begin{equation*}   r[n] = \sum \limits _{m=-1} ^{2} s[n-m] \end{equation*}

which is basically addition of s[n-m] for m=-1,0,1 and 2. We can simply break it down to a more recognizable form by substituting values of m as

    \begin{equation*}   r[n] = s[n+1] + s[n-0] + s[n-1] + s[n-2] \end{equation*}

Now we can easily draw the time shifted versions of s[n] and add them together to find the resultant signal. An example with a unit impulse signal \delta[n] and its time shifted versions is illustrated in Figure below.

Result of summing a signal with its time shifted versions

Flipping or Time-Reversal

When the independent variable n is replaced by -n, the signal is reflected or flipped around the time origin n=0 because the sample at n=+1 shifts to n=-1, sample at n=-5 shifts to n=+5, and so on. Figure below illustrates this concept by plotting s[-n] and s[-n+3].

A signal plot with its flipped and time shifted versions

Note that the rules of shifting to the left or right also become reverse due to the flipped time-axis, -n, itself. For example, from the perspective of intuitive method above, an axis of -n instead of n suggests that the past becomes the future, and vice versa. Hence, s[-n+3] first flips the signal around time origin, then travels 3 units to the past to label it the new NOW (time index 0).

Circular Shift

Circular shift is very similar to time shifting of a signal, except that the available axis for time shifting a signal is from -\infty to +\infty while we only focus on a segment of N samples for a circular shift.

If a signal s[n] is circularly right shifted by m, the samples of the signal s[n] that fall off to the right of length-N segment reappear at the start. Similarly, if s[n] is circularly left shifted by m, the samples of the signal s[n] that fall off to the left of length-N segment reappear from the end. Just like a video game character which disappears at one end of the screen to emerge from the other (Pac-man, for example).

A simple rule to remember circular shift is "what goes around comes around".

As circular shift is done with respect to a length-N segment, shifts are computed modulo N and denoted as s[(n-m) \:\textmd{mod}\: N], where (n-m)\: \textmd{mod} \:N means shifting the signal as we normally would, but bringing them back in the range 0\le n \le N-1 from the opposite side. For example, the next Figure shows two examples of circular shifts:

A signal plot with its circularly shifted versions

  1. s[(n-1) \:\textmd{mod}\: 8] is a right shift of 1 in every respect, except for sample at time index 7. Instead of going to index 8, it returns from the left at index 0.
  2. Again, s[(n+3) \:\textmd{mod}\: 8] is a left shift of 3 for most samples, except for samples at time indices 0, 1 and 2. Instead of going to negative time, these three samples return from the right at indices 5, 6 and 7, respectively.

As an exercise, try drawing s[(n+7) \:\textmd{mod}\: 8] and s[(n-5) \:\textmd{mod}\: 8]. You will find that these shifts are actually the same as s[(n-1) \:\textmd{mod}\: 8] and s[(n+3) \:\textmd{mod}\: 8], respectively.

An interesting question at this stage is: what will be the result of a circularly flipped signal s[(-n) \:\textmd{mod}\: N]? The logic of circular shift stays the same. Like regular flipping, the sample at index 0 remains fixed. The sample at index 7 should take a position at -7 but there is no negative indexing in circular notation and (-7) \:\textmd{mod}\: 8 = -7+8 = 1, which takes it to index 1. Figure below shows s[(-n) \:\textmd{mod}\: N] = s[-n+N] for the same signal as above.

A circularly flipped signal

The significance of circular shift will become clear when we discuss the Discrete Fourier Transform (DFT) later.

If you found this article useful, you might want to subscribe to my email list below to receive new articles.

DFT Examples

Magnitude and phase of the DFT of a rectangular signal for L = 7, N= 16 and starting sample shifted by one

Having covered the Discrete Fourier Transform (DFT) and the concept of phase, we discuss a few examples of DFTs of some basic signals that will help not only understand the Fourier transform but will also be useful in comprehending concepts discussed further.

A Rectangular Signal

A rectangular sequence, both in time and frequency domains, is by far the most important signal encountered in digital signal processing. One of the reasons is that any signal with a finite duration, say T seconds, in time domain (that all practical signals have) can be considered as a product between a possibly infinite signal and a rectangular sequence with duration T seconds. This is called windowing and a rectangular sequence is the simplest form of a window. Windowing is a key concept in implementation of many DSP applications.

Let us compute the N-point DFT of a length-L rectangular sequence

(1)   \begin{equation*}         s_I[n] = \left\{ \begin{array}{l}         1, \quad n_s \le n \le n_s+L-1 \\         0, \quad \textmd{otherwise} \\         \end{array} \right.     \end{equation*}

shown in Figure below, where N \ge L.

A rectangular signal with length L

Since this sequence is real with no Q component in time domain, the I component in frequency domain from DFT definition can be expressed as

(2)   \begin{align*}         S_I[k] &= \sum \limits _{n=n_s} ^{n_s+L-1} s_I[n] \cos 2\pi\frac{k}{N}n  \nonumber \\                              &= \sum \limits _{n=n_s} ^{n_s+L-1} \cos 2\pi\frac{k}{N}n   \\                              &= \sum \limits _{n=n_s} ^{n_s+L-1} \cos 2\pi\frac{k}{N}n~ \frac{\sin \pi\frac{k}{N}}{\sin \pi\frac{k}{N}} \nonumber     \end{align*}

Let \theta = 2\pi k/N and using the identity \cos(A)\sin(B) = 0.5 \left\{ \sin(A+B) - \left.\sin(A-B) \right\}, we get

    \begin{align*} S_I[k] &= \sum \limits _{n=n_s} ^{n_s+L-1} \cos n\theta~ \frac{\sin \theta/2}{\sin \theta/2} \\                                     &= \frac{1}{2\sin \theta/2} \sum \limits _{n=n_s} ^{n_s+L-1} \left[ \sin \left( n+\frac{1}{2}\right)\theta - \sin \left( n-\frac{1}{2}\right)\theta \right] \\                                     &= \frac{1}{2\sin \theta/2} \left[ \sin \left( n_s+L-\frac{1}{2}\right)\theta - \sin \left( n_s-\frac{1}{2}\right)\theta \right] \\     \end{align*}

where all the other terms in the summation cancel out. Using the same identity as above

    \begin{align*} S_I[k] &= \frac{1}{\sin \theta/2} \cos \left(n_s + \frac{L-1}{2}\right)\theta \cdot \sin\left(\frac{L}{2} \right)\theta  \\ &= \frac{\sin L \theta/2}{\sin \theta/2} \cos \left(n_s + \frac{L-1}{2}\right)\theta \nonumber     \end{align*}

Plugging in the expression back for \theta,

(3)   \begin{align*} S_I[k] &= \frac{\sin \pi L k/N}{\sin \pi k/N} \cos \left[ 2\pi \frac{ k}{N}\left(n_s + \frac{L-1}{2}\right) \right]     \end{align*}

Similarly, Q component can be found from DFT definition,

    \begin{align*} S_Q[k] &= \sum \limits _{n=n_s} ^{n_s+L-1} -s_I[n] \sin 2\pi\frac{k}{N}n   \\  &= \sum \limits _{n=n_s} ^{n_s+L-1} -\sin 2\pi\frac{k}{N}n       \end{align*}

Following the same procedure as I component, and using the identity \sin(A)\sin(B) = \frac{1}{2} \left\{ \cos(A-B) -\right. \left. \cos(A+B) \right\}, the Q component of its DFT is given by

(4)   \begin{align*} S_Q[k] &= -\frac{\sin \pi L k/N}{\sin \pi k/N} \sin\left[ 2\pi\frac{k}{N} \left(n_s + \frac{L-1}{2}\right) \right]     \end{align*}

Despite its simplicity, there is a lot of information hidden and several interesting conclusions to be drawn here for which we continue further discussion below.

Magnitude and Phase

Applying the definitions of magnitude and phase to Eq (3) and Eq (4) and using \cos^2 A + \sin^2 A = 1, we get the magnitude and phase of the DFT of a rectangular signal.

(5)   \begin{equation*}         |S[k]| &= \frac{\sin \pi L k/N}{\sin \pi k/N}  \end{equation*}

(6)   \begin{equation*}         \measuredangle S[k] &= -2\pi\frac{k}{N} \left(n_s + \frac{L-1}{2}\right)      \end{equation*}

Magnitude and phase (as well as I and Q parts) of an all-ones DFT for L = N = 16

The above Figure displays the magnitude and phase plots for the DFT of a rectangular signal with L=N=16 which in this case are similar to the I and Q plots, respectively. In general, magnitude-phase and IQ plots convey different information, many examples of which we will encounter throughout this text. In most situations, magnitude-phase plot delivers a great deal of information while in some others, IQ plot is more relevant. How a specific value of n_s affects the phase plot is discussed in the concept of phase.

DFT, Frequency Domain Sampling and Leakage

For DFT of a rectangular signal, the IQ equations are given in Eq (3) and Eq (4), and the magnitude-phase equations in Eq (5) and Eq (6). The corresponding figures are drawn in the Figure above with single impulses at bin 0.

The question is: How can such complex equations generate such simple figures? The answer is that it was a special case due to the whole sequence being equal to one. For an L<N and using Eq (6), the rectangular signal can be made symmetric around zero position, as shown in Figure below for L = 7, N = 16 and n_s = -(L-1)/2 (which is the same as n_s = N -(L-1)/2 due to DFT input periodicity in DFT periodicity Eq).

Time domain periodicity of a rectangular sequence is shown from DFT computation perspective

Now consider the case of L = 7, N = 16 and n_s = -(L-1)/2-1 = -4. The sequence can be imagined as shifted to the left by 1 from its symmetric position around zero. I and Q plots from Eq (3) and Eq (4) are shown in Figure below.

I and Q components of the DFT of a rectangular signal for L = 7, N= 16 and starting sample shifted by one

Similarly, the magnitude and phase plots from Eq (5) and Eq (6) are plotted in Figure below.

Magnitude and phase of the DFT of a rectangular signal for L = 7, N= 16 and starting sample shifted by one

A clear shape of sinc function in terms of \sin (\pi L k/N) / \sin (\pi k/N) is visible in magnitude plot which is sampled at discrete frequencies k/N. Now we can recognize that the plots in this Figure were also sinc functions but sampled at the peak value at bin 0 and at zero crossings for all other bins.

To comprehend the reason why energy appeared in other frequency bins as well, consider that as explained in the article about complex numbers, a complex sinusoid is composed of \cos(\cdot) and \sin(\cdot) as I and Q components, respectively. These \cos(\cdot) and \sin(\cdot) are orthogonal to each other over a complete period, and \cos(\cdot) (\sin(\cdot)) of one frequency k/N is also orthogonal to \cos(\cdot) (\sin(\cdot)) of other frequencies k'/N, provided that k' are also integers, i.e.,

(7)   \begin{equation*}                 \begin{aligned}                     \sum \limits _{n=0} ^{N-1} \cos 2\pi \frac{k}{N}n \cdot \sin 2\pi \frac{k}{N}n = 0 \\                     \sum \limits _{n=0} ^{N-1} \cos 2\pi \frac{k}{N}n \cdot \cos 2\pi \frac{k'}{N}n = 0 \\                     \sum \limits _{n=0} ^{N-1} \sin 2\pi \frac{k}{N}n \cdot \sin 2\pi \frac{k'}{N}n = 0                 \end{aligned}             \end{equation*}

The DFT finds the contributions of analysis frequencies F = F_S \cdot k/N for for k = -N/2, \cdots,-1,0,1, \cdots,N/2-1 in an input signal, which are all integer multiples of a fundamental frequency F_S/N. It is due to this integer multiplicity that DFT is able to find each k-th contribution independently of all others. And if the input signal contains contributions from only these frequencies, the DFT output is proportional to the magnitude at the contributing frequency bins and zero at the remaining bins.

In a real scenario, the input data sequence is not bound to contain energy precisely at a set of given analysis frequency bins. If the input has a signal component at some intermediate frequency between these integer multiples of F_S/N, say 1.3 F_S /N, Eq (7) does not hold and this input signal shows up to some degree in all N output bins of our DFT due to unaligned sampling instants in frequency domain. This is known as DFT leakage.

When we perform the DFT on real-world finite-length time sequences, DFT leakage is an unavoidable phenomenon. Let us construct an example to observe this in detail.

Signal frequency and analysis frequency are the same, resulting in no DFT leakage


Assume a signal with frequency 4 kHz at a sample rate of F_S = 16 kHz.

    \begin{align*}       s[n] = \sin 2\pi \frac{4}{16} n     \end{align*}

The solid blue curve is shown in Figure above in time domain along with one analysis frequency F_4 = F_S \cdot k/N = 16000 \cdot 4/16 = 4 kHz. Note that both the input frequency and the analysis frequency F_4 complete four full cycles during the sampling interval and hence its DFT, plotted in Figure above, has two impulses at bins 4 and -4 with zero input from all the other bins. The shape of the actual curve is the same sinc function but it is sampled in frequency domain at just the right points — integer frequency bins due to integer number of cycles of the input in time domain.

Now let us change the input signal slightly by making the input frequency equal to 3.7 kHz as shown in Figure below.

    \begin{align*}       s[n] = \sin 2\pi \frac{3.7}{16} n     \end{align*}

Observe in this Figure below that the analysis frequency F_4 completes four full cycles during that interval, while the frequency 3.7 kHz in the original signal s[n] does not have integer number of cycles over 16-sample interval, causing the input energy to leak into all the other DFT output bins. The k = 3 bin is not zero because the sum of the products of the input sequence and the k = 3 analysis frequency is no longer zero (same is also true for, say, k=4). This leakage causes any input signal whose frequency is not exactly at a DFT bin center to leak into all of the other DFT output bins. The shape of the sinc function did not change as compared to a 4 kHz input but it is sampled in frequency domain at non-ideal points — fractional frequency bins due to non-integer number of cycles of the input in time domain.

Signal frequency and analysis frequency are not the same, resulting in DFT leakage to other bins

One final question: an input sinusoid at 3.7 kHz sampling the sinc function at unaligned points in frequency domain makes sense, but why the graph in this Figure exhibits a similar kind of leakage? The reason is that an all-ones rectangular sequence with L=N=16 can be considered a single complex sinusoid at frequency 0 but its truncated version with L = 7, N=16 is not. It is actually made up of all N sinusoids just like a periodic square wave we encountered in this Figure.

Mainlobe Peak

The DFT of a rectangular signal has a mainlobe centered about the k = 0 point. Its amplitude cannot be found by plugging in k=0 in Eq (5) because both the numerator and denominator become zero resulting in undefined 0/0 expression. Although a mathematical trick (known as L’Hôpital’s rule) can be applied to compute it mathematically, we take an easier course. The peak amplitude of the mainlobe is L because at k = 0, DFT definition dictates that the DFT S[0] is the sum of all original samples due to \cos 2\pi (k/N) n = 1 and \sin 2\pi (k/N) n = 0. Then, the sum of L unity-valued samples is L. Consequently, the peak value is seen to be L = 16 in this Figure and L = 7 in this Figure.

Mainlobe Width and Zero Crossings

The width of the mainlobe is defined by zero crossings of the curve. Since \sin \pm \pi = 0, the first zero crossing occurs when the numerator argument in Eq (5), \sin \pi L k/N, is equal to \pi. All other zero crossings are integer multiples of the first. So the mainlobe width is given by the value of the first zero crossing k_{zc} as

    \begin{align*}           \pi L \frac{k_{zc}}{N} &= \pi \\            k_{zc} &= \frac{N}{L}         \end{align*}

This value is confirmed from N/L = 1 in this Figure and N/L = 16/7 = 2.29 in this Figure. A zero crossing right at sample 1 in this Figure illustrates that it was sampled at peak value for bin 0 and at zero for all other bins.

DFT Phase

Most of the discussion until now was around the magnitude plots. Let us understand the concept of phase again through the DFT of a rectangular signal. Now the phase plot in this Figure for L=7, N=16 and n_s=-(L-1)/2-1 has been drawn in Figure below after unwrapping 180^\circ phase jumps which arose due to changing I and Q signs. The resulting phase is a straight line with a positive slope equal to 22.5^\circ. Where did this number come from?

Unwrapped DFT phase

We learned in in the article about phase that a time shift of n_0 samples results in phase rotation of \Delta \theta (k) = 2\pi (k/N) n_0, the direction of which depends on the direction of time shift. For time traveling in the past (i.e., a signal delay), the phase rotation is also negative while for time traveling in the future (i.e., a signal advance), the phase rotation is also positive.

To complete the picture, we need one extra piece of information that we prove later: the DFT of a real and even symmetric signal is purely real with 0 Q part. Consequently, its phase is equal to 0 or \pi (depending on the sign of I part). In our example, an even symmetric signal would have been obtained for n_s=-(L-1)/2. Then, the phase plot would be 0 or \pi as shown in Figure (part a) below.

Phase plots for different time shifts

However, for n_s = -(L-1)/2-1, it is a left shift of that even symmetric signal by 1 sample. Thus, plugging n_0=+1 in the expression 2\pi (k/N) n_0 from this Eq gives the phase rotation \theta (k) for each frequency bin as

    \begin{align*}         \Delta \theta(k) &= 2\pi \frac{k}{N} n_0 \\                   &= 2\pi \frac{k}{N}, \quad k = -N/2,\cdots,-1,0,1,\cdots,N/2-1     \end{align*}

In this case, N was equal to 16. Starting from k = 0, the phase shift can be seen to be 0 from this Figure. For all k,

    \begin{align*}         \Delta \theta(0)  &= 2\pi \frac{0}{N} \times \frac{180^\circ}{\pi} = 0 \\         \Delta \theta(\pm1)  &= 2\pi \frac{\pm1}{N} \times \frac{180^\circ}{\pi} = \pm 22.5^\circ \\         \Delta \theta(\pm2)  &= 2\pi \frac{\pm2}{N} \times \frac{180^\circ}{\pi} = \pm 45 ^\circ \\         \Delta \theta(\pm3)  &= 2\pi \frac{\pm3}{N} \times \frac{180^\circ}{\pi} = \pm 67.5^\circ \\         &\cdots \\         &\cdots     \end{align*}

A linear slope of 22.5^\circ is thus verified. Part (b) of above Figure shows the phase plot for a right shift of 1, i.e., n_s = -(L-1)/2+1. Observe a negative slope of -22.5^\circ when adjusted for 180^\circ phase jumps.

A General Sinusoid

The DFT of a general sinusoid can be derived similarly by plugging the expression of a complex sinusoid in DFT definition and following the same procedure as in the rectangular sequence example.

Nevertheless, having understood the above concepts, we can see how the magnitude and phase plots of the DFT of a general sinusoid look like by an easier method. As an all-ones rectangular sequence is nothing but a complex sinusoid with frequency 0 with length L=N, the DFT magnitude of a general complex sinusoid with frequency k' (which can be a non-integer) can be found by putting L=N (as it spans the whole length), n_s=0 (as it starts at 0) and k-k' instead of k in Eq (5) and Eq (6) as

(8)   \begin{align*}                 |S[k]| &= \frac{\sin \pi (k-k')}{\sin \pi (k-k')/N} \\         \measuredangle S[k] &= -2\pi\frac{k-k'}{N} \left(\frac{N-1}{2}\right)             \end{align*}

Similarly, the DFT of a real sinusoid \cos[2\pi (k'/N)n] can be seen as the sum of the above expression with a similar expression replacing k-k' with k+k' because each real sinusoid consists of two complex sinusoids scaled by half.

For example, consider a signal shown in Figure below and consisting of two sinusoids at 1 kHz and 2 kHz as

    \begin{align*}         s(t) &= s_1(t) + s_2(t) \\              &= \sin(2\pi 1000 t) + 0.75\sin(2\pi 2000 t + 120 ^\circ)     \end{align*}

A signal formed by addition of two sinusoids

It can be seen that s[n] has only an I component with zero Q component. Sampling the above signal at a rate of 1/T_S = F_S = 8 kHz produces

(9)   \begin{align*}         s[n] &= \sin(2\pi 1000 nT_S) + 0.75\sin(2\pi 2000 nT_S + 120^\circ) \nonumber \\              &= \sin\left(2\pi \frac{1}{8}n\right) + 0.75\sin\left(2\pi \frac{2}{8}n + 120^\circ \right)      \end{align*}

Our DFT analysis frequencies, from this Eq, for an 8 point DFT are

    \begin{align*}         F &= F_S \cdot \frac{k}{N} \\         k = 0  &\Rightarrow 8000 \cdot\frac{0}{8} = 0~ \textmd{kHz} \\         k = \pm1  &\Rightarrow 8000 \cdot\frac{\pm1}{8} = \pm1~ \textmd{kHz} \\         k = \pm2  &\Rightarrow 8000 \cdot\frac{\pm2}{8} = \pm2~ \textmd{kHz} \\         k = \pm3  &\Rightarrow 8000 \cdot\frac{\pm3}{8} = \pm3~ \textmd{kHz} \\     \end{align*}

So in this case, bin 1 corresponds to an actual frequency of 1 kHz, bin 2 to 2 kHz, and so on. The DFT S[k] can be found by applying DFT definition and is plotted in Figure below.

I and Q parts and magnitude and phase plots of a signal composed of two sinusoids

From magnitude plot of this figure, observe that the DFT has detected two real sinusoids in this signal because the impulses at bins 1 and -1 indicate the presence of two complex sinusoids that combine to form one real sinusoid at a frequency 8000\cdot1/8 = 1 kHz. A similar argument holds for the other frequency of 2 kHz.

DC or Average Value

The DC, or average, value of this signal \frac{1}{N}\sum s[n] is 0 which is evident from Eq (9) as the average value of a sinusoid over an integral number of cycles is 0.


When an input signal contains a complex sinusoid of peak amplitude A with an integral number of cycles over N input samples, the output magnitude of the DFT for that particular sinusoid is AN. This can be checked by plugging in the expression for a complex sinusoid into DFT definition. Using Eq (7), the DFT output for a complex sinusoid is given as

    \begin{align*}                 \sum  \limits _{n=0} ^{N-1} \cos 2\pi \frac{k}{N}n \cdot \cos  2\pi \frac{k}{N}n + \sin 2\pi \frac{k}{N}n \cdot \sin 2\pi \frac{k}{N}n \\                 \sum  \limits _{n=0} ^{N-1} \sin 2\pi \frac{k}{N}n \cdot \cos 2\pi \frac{k}{N}n - \cos 2\pi \frac{k}{N}n \cdot \sin 2\pi \frac{k}{N}n               \end{align*}

Using the identities \cos A \cos B + \sin A \sin B = \cos (A-B) and \sin A \cos B - \cos A \sin B = \sin (A-B),

    \begin{align*}                 \sum  \limits _{n=0} ^{N-1}  \cos 0 &= N \\                 \sum  \limits _{n=0} ^{N-1} \sin 0 &= 0                           \end{align*}

Thus, the output magnitude of the DFT is proved as AN.

For a real sinusoid, s_Q[n] is 0 and only the first term in I part of the above equation survives. Since \cos^2 A = 1/2(1+\cos 2A), the output magnitude of the DFT for a real sinusoid is AN/2.

Considering the fact that s[n] is composed of two real sine waves with amplitudes 1 and 0.75, we can see in this Figure that 1 kHz sine wave has a magnitude 1\times N/2 = 4 and 2 kHz sine wave has a magnitude 0.75 \times N/2 = 3.

But if the sinusoid in a rectangular signal is real with frequency 0, why is the peak value in the magnitude plot in this Figure equal to N = 15 rather than N/2 = 7.5? This is because the DFT of a regular real sinusoid is two impulses with amplitude N/2, one at that frequency and the other at its negative counterpart, but at frequency 0, both of these impulses merge together to give a magnitude of N. Another way to understand it is that an all-ones sequence is actually a complex sinusoid at frequency 0 because it has an all-ones sequence in I part and all-zeros sequence in Q part.

    \begin{align*}                 \cos 2\pi \frac{k}{N}n &= \cos 2\pi \frac{0}{N}n = 1, \quad\quad n = 0,\cdots,N-1\\                 \sin 2\pi \frac{k}{N}n &= \sin 2\pi \frac{0}{N}n = 0, \quad\quad n = 0,\cdots,N-1               \end{align*}


Referring to the phase plot and going back to the DFT definition, assume that the input is \cos 2\pi (k/N) n. The DFT output is given as

    \begin{align*}                 \sum \limits _{n=0} ^{N-1} \cos 2\pi \frac{k}{N}n \cdot \cos 2\pi \frac{k}{N}n + 0 \cdot \sin 2\pi \frac{k}{N}n &= a\\                 \sum \limits _{n=0} ^{N-1} 0 \cdot \cos 2\pi \frac{k}{N}n - \cos 2\pi \frac{k}{N}n \cdot \sin 2\pi \frac{k}{N}n &= 0               \end{align*}

for an arbitrary number a and orthogonality of \cos(\cdot) and \sin(\cdot) over a complete period. The phase is \tan^{-1} (0/a) = 0 for positive a and \tan^{-1} 0/-a + \pi = \pi for negative a. Therefore, a 0 phase at a particular frequency F = F_S \cdot k/N is with respect to a cosine wave at that same frequency.

In this Figure, bin 1 frequency at 8000 \cdot 1/8 = 1 kHz has a phase of -90 ^\circ. Is it a cosine with a phase of -90^\circ? From the identity \cos (A-90^\circ) = \sin (A), it is indeed a sine waveform with an initial phase of 0 which can be confirmed from the first term \sin 2\pi (1/8)n of s[n] in Eq (9). The corresponding phase at bin -1 is obviously -(-90^\circ)=+90 ^\circ, see this Figure.

As for the second term 0.75 \sin\left\{ 2\pi (2/8)n + 120^\circ\right\}, it is a sine at 2 kHz with a phase shift of 120 ^\circ, or a cosine with a phase of 120^\circ-90^\circ = 30 ^\circ as shown in this Figure for bin 2.

Notice in this Figure how the signal is composed of two sinusoids at 1 and 2 kHz, respectively, where former is a cosine with a phase of -90^\circ (or a sine with 0^\circ) and the latter is a cosine with a phase of 30^\circ (or a sine with 120^\circ). Now referring to its time domain plot in this Figure, the first sinusoid s_1(t) is positioned around the origin according to its -90^\circ cosine (or 0^\circ sine) phase, while the second sinusoid s_2(t) is positioned around the origin according to its 30^\circ cosine (or 120^\circ sine) phase. Through the phase plot, the DFT in fact finds the time alignments of all the sinusoids at bin frequencies F_S \cdot k/N.

Time IQ vs Frequency IQ

Sometimes it is easy to get confused from the fact that Q component of s[n] is 0 in the above example, leading to an incorrect phase result of 0 or \pi. However, as illustrated in this Figure, we have to differentiate IQ-plane of time domain from IQ-plane of frequency domain. The Q component here is 0 in time domain only but the phase plot is determined by IQ components in frequency domain. There, a real sinusoid is a sum of two complex sinusoids and the phase of those two complex sinusoids in frequency IQ-plane determines the starting sample of the real sinusoid in time domain.

Do remember that the plots shown in this Figure are — once again — sinc functions overlapping each other. However, since the signal consists of two exact analysis frequencies, the frequency domain is sampled at the precise locations of zero crossings. That being the case, the sinc function becomes invisible and looks like two sets of impulses only.

In the meantime, if you found this article useful, you might want to subscribe to my email list below to receive new articles.

The Unit Impulse

Having known the DFT of a rectangular signal, we have two ways to find the Fourier transform of a unit impulse.

[Time-Frequency Duality] A closer look at DFT and iDFT equations reveal that the forward and inverse transform are almost identical, except the scaling factor 1/N and direction of rotations of analysis sinusoids. Therefore, time and frequency domains are dual and DFT of a signal in time domain can be derived by the iDFT of a signal in frequency domain. For example, a single impulse at frequency bin 0 in this Figure is an all-ones rectangular sequence in time domain. By duality, the inverse is also true: a single impulse in time domain corresponds to an all-ones rectangular sequence in frequency domain.
[Rectangular signal] From a general rectangular sequence as in this Figure, it is evident that a unit impulse is also a rectangular sequence with length L = 1. Therefore,

(10)   \begin{align*}         |S[k]| &= \frac{\sin \pi k/N}{\sin \pi k/N} = 1      \end{align*}

Since the starting sample n_s = 0, the angle is equal to 0. This DFT was graphically illustrated in this Figure.

The Sampling Sequence

The sampling sequence is a sequence of unit impulses repeating with a period M within our observation window (and owing to DFT input periodicity, outside the observation window as well). Figure below illustrates the sampling sequence in time domain for M=3 and N=15.

A sampling sequence with period 3 in time domain

To compute its DFT, consider that p_I[n] = p[n] and p_Q[n]=0. Then,

    \begin{align*}         P_I[k] &= \sum \limits _{n=0} ^{N-1} p[n] \cos 2\pi\frac{k}{N}n     \end{align*}

Since p[n]=0 except when n=M, we can write p[Mm] = 1 where m=0,1,\cdots,N/M-1. We are assuming N/M as an integer here because otherwise p[n] will not be periodic. So in the above example, m = 0,1,2,3,4 for non-zero values of n at 0, 3, 6, 9 and 12.

    \begin{align*}         P_I[k] &= \sum \limits _{m=0} ^{N/M-1} \cos 2\pi\frac{k}{N} M m = \sum \limits _{m=0} ^{N/M-1} \cos 2\pi\frac{k}{N/M} m     \end{align*}

Note that the above equation is very similar to Eq (2) encountered while computing the DFT of a rectangular sequence. Therefore, substituting both the length of the sequence L and observation window N equal to N/M in Eq (5) and doing the same for Q part, we get

(11)   \begin{align*}         |P[k]| &= \frac{\sin \pi k}{\sin \pi k M/N}      \end{align*}

Magnitude and Phase

The sequence is plotted in frequency domain in Figure below, where both I and Q components are shown for M = 3 and N=15. Since the sequence is aligned in time such that it is symmetric with respect to zero, the phase is zero in frequency domain. So the magnitude plot is the same as the I part.

DFT of a sampling sequence in frequency domain with period 3 in time domain

Mainlobe Peak

In the DFT of a rectangular signal, we saw that both the numerator and denominator become equal to zero for k=0. In that case, the peak of the mainlobe was equal to L, the length of the sequence. We found this value by plugging k=0 in the DFT definition and deduced that the result is just a sum of all time domain samples because \cos 2\pi k/N = 1 and \sin 2\pi k/N = 0. Here in this case, the peak value can easily be seen as the sum of N/M unit impulses and hence equal to N/M = 5.

Remember from DFT of a general sinusoid derived above that the DFT of a complex sinusoid with amplitude A in time has a magnitude AN in frequency domain. Here, the spectral replicas have a peak magnitude of 5 instead of 15 which suggests that the actual spectrum has been scaled down by a factor of 1/M=1/3. This is shown in Figure above.

Mainlobe Positions

There are multiple impulses in frequency domain here: more than one as in DFT of an all-ones rectangular sequence but less than N as in the DFT of a unit impulse. Observe from Eq (11) that when the denominator is non-zero, the spectrum is clearly zero. When both the numerator and denominator are zero, the peak values are N/M as above. To find these locations, check where the denominator is an integer multiple of \pi as well.

    \begin{align*}       \pi k_{\textmd{peak}} \frac{M}{N} &= \textmd{integer} \cdot \pi  \\       k_{\textmd{peak}} &= \textmd{integer} \cdot \frac{N}{M}     \end{align*}

In our example, these peaks turn out to be 0 and \pm 5 as shown in Figure above. If you guessed that these impulses in frequency domain are actually sinc functions sampled at just the peak and zero values, you are right (compute a length-32 DFT of this sequence instead of length-15, for example).


Finally, later in another post, we will summarize some important properties of the DFT in a table. In that table, one of the most important properties of DFT we use over and over again is the Parseval’s relation that relates the energy of a signal in time domain with the same in frequency domain.

(12)   \begin{equation*}         E_s = \sum _{n=0} ^{N-1} |s[n]|^2 = \frac{1}{N} \sum _{n=0} ^{N-1} |S[k]|^2     \end{equation*}

In words, energy of a signal in time domain is equal to its energy in frequency domain scaled by 1/N. The intuitive reason for this scaling factor in frequency domain is that as discussed above, the DFT output for a complex sinusoid with amplitude A is AN, an N time magnification.