Skip to content

Phase Spectrum: What the Magnitude Hides

Copy this iframe to your website:

1
<iframe src="https://dmccreary.github.io/signal-processing/sims/phase-spectrum/main.html" width="100%" height="638px" scrolling="no"></iframe>

Run MicroSim in Fullscreen

Description

A magnitude spectrum \(|X(f)|\) tells you which frequencies are present and how strong they are. The phase spectrum \(\angle X(f)\) tells you how those components line up in time, and that is what gives a signal its shape. The View radio buttons switch between three experiments.

A: Harmonics. The signal is \(x(t) = \sum_{k=1}^{3} A_k \cos(2\pi k f_0 t + \phi_k)\) with \(f_0 = 1\) Hz and fixed amplitudes \(A_k = 1, \tfrac12, \tfrac13\). Three sliders set the phases \(\phi_1, \phi_2, \phi_3\) (−180° to 180°), and the preset buttons load all 0°, a sawtooth (all −90°), a delay (−60°, −120°, −180°) or random phases. The magnitude bars never move, the RMS stays 0.825, but the waveform and its peak change. The dashed gray curve is the same magnitudes with every phase set to 0.

B: Time shift. A Gaussian pulse, rectangular pulse or sawtooth (100 samples over 1 s, so the DFT bins are 1 Hz apart) is delayed by \(\tau\). The shift theorem

\[x(t - \tau) \;\longleftrightarrow\; X(f)\,e^{-j2\pi f \tau}\]

leaves \(|X(f)|\) unchanged and adds a phase ramp of slope \(-2\pi\tau\) rad/Hz. The phase is shown wrapped to \((-\pi, \pi]\) or, with Unwrap phase, as a continuous line. A cursor reads \(|X|\) and \(\angle X\) at one frequency. Bins with \(|X|\) below 0.1% of the maximum have no meaningful phase and are marked ×.

C: Swap. Two signals A and B go through a 256-point DFT and are rebuilt from the magnitude of one and the phase of the other, from the magnitude alone (zero phase), or from the phase alone (\(|X| = 1\)). The read-outs give the correlation coefficient \(r\) of each rebuilt signal with A and with B.

This MicroSim supports Chapter 7: DFT, FFT and Frequency Domain Analysis.

Lesson Plan

Learning Objectives

After using this MicroSim, students will be able to:

  1. Explain why signals with identical magnitude spectra can have very different waveforms and peak values
  2. Identify phases that grow linearly with frequency, \(\phi_k = k\,\phi_1\), as a pure time delay \(\tau = -\phi_1 / (360^\circ f_0)\)
  3. Calculate the phase \(-2\pi f \tau\) added by a delay \(\tau\) and the interval \(1/|\tau|\) at which the wrapped phase repeats
  4. Distinguish \(2\pi\) wrapping jumps from \(\pi\) jumps caused by sign changes of a real spectrum
  5. Analyze the swap experiment to conclude that the timing of a signal's features is carried by its phase

Target Audience

Undergraduate students in a first signals and systems or digital signal processing course who have met the DFT. Plan 25 minutes for the activities below.

Prerequisites

  • Complex numbers in polar form, magnitude and angle (see the Complex Plane MicroSim)
  • Sinusoids \(A\cos(2\pi f t + \phi)\) and what the phase \(\phi\) does to them
  • The DFT and the magnitude spectrum (Chapter 7)

Activities

Activity 1: Same magnitudes, different shapes (6 min). In view A the default phases are all −90° (the Sawtooth preset): the read-out shows peak \(|x|\) = 1.44 and RMS = 0.825. Press All 0°. The three cosines now peak together at \(t = 0\) and the peak rises to 1.83, yet the magnitude bars and the RMS (0.825) do not change. Press Delay (−60°, −120°, −180°): the blue curve is the dashed all-0° curve moved right by 0.167 s, and the peak is again 1.83. Set the phases to −45°, −90° and −135°: the note reports a pure delay of 0.125 s. Now move only \(\phi_2\) to −80°: the phases are no longer proportional to \(k\), and the shape changes.

Activity 2: A delay is a phase ramp (7 min). Choose view B with the Gaussian pulse and \(\tau\) = 0.05 s. The header reports slope \(-2\pi\tau\) = −0.314 rad/Hz (−18.0°/Hz) and a wrap every 20.0 Hz. With the cursor at 5 Hz the read-out shows \(\angle X\) = −90.0°; at 15 Hz it shows +90.0°, because −270° wraps to +90°. Check Unwrap phase: the same bin now reads −4.712 rad (−270.0°), and the dots form one straight line down to −12.252 rad at 39 Hz (bins 40-50 are marked undefined). Set \(\tau\) = 0.10 s: the slope doubles to −0.628 rad/Hz and the wrapped phase repeats every 10.0 Hz. Set \(\tau\) = −0.05 s: the phase now rises by 18° per hertz (+90.0° at 5 Hz). Through all of this \(|X(5\ \text{Hz})|\) stays at 0.895.

Activity 3: Not every jump is a wrap (6 min). Choose the sawtooth with \(\tau\) = 0: every defined bin from 1 to 48 Hz has phase +90°, a horizontal line. Choose the rectangular pulse, still at \(\tau\) = 0: the phase is 0° up to 9 Hz and 180° from 10 to 18 Hz, because the pulse's sinc-shaped spectrum is real and changes sign. Set \(\tau\) = 0.05 s with the cursor at 9 and then 10 Hz: the phase goes from −162° to 0° instead of falling another 18°. Check Unwrap phase: the dots follow the dashed line until 9 Hz, then climb by \(\pi\) at each sign change, while keeping the slope \(-2\pi\tau\) between the jumps.

Activity 4: The swap experiment (6 min). Choose view C with A = rectangular pulse, B = damped chirp and Swap the phases. \(|A|\) with \(\angle B\) oscillates like the chirp (\(r_A\) = −0.18, \(r_B\) = 0.64), and \(|B|\) with \(\angle A\) is a pulse between 0.10 and 0.25 s (\(r_A\) = 0.64, \(r_B\) = −0.08). Change A to the sawtooth burst: again each result follows its phase source (\(r_B\) = 0.74 and \(r_A\) = 0.74). Switch to Zero phase (|X| only): both rebuilt signals are symmetric about \(t = 0\) with their peak at \(t\) = 0.000 s, whatever the original timing. Switch to Phase only (|X| = 1): the rebuilt pulse is reduced to spikes at its edges, 0.10 and 0.25 s, and still correlates with A (\(r_A\) = 0.41).

Assessment

  1. In view A, all-0° phases give a peak of 1.83 and all −90° phases give 1.44. Why is the RMS 0.825 in both cases? Answer: the power of a sum of sinusoids at different frequencies depends only on their amplitudes: \(\sqrt{(1^2 + 0.5^2 + 0.333^2)/2} = 0.825\). Phase moves energy around in time but does not change it.
  2. What waveform do the phases −45°, −90° and −135° produce for the 1, 2 and 3 Hz harmonics? Answer: the phases are \(k \times (-45^\circ)\), a linear phase, so the result is the all-0° waveform delayed by \(\tau = 45^\circ / (360^\circ \times 1\ \text{Hz}) = 0.125\) s, with the same peak of 1.83.
  3. A wrapped phase spectrum falls by 36° per hertz and wraps every 10 Hz. What delay produced it? Answer: slope \(-2\pi\tau\) = −36°/Hz gives \(\tau = 36/360 = 0.10\) s; the wrap interval \(1/\tau\) = 10 Hz agrees.
  4. A pulse is delayed by 0.02 s. What phase does the delay add at 50 Hz, and why can the wrapped phase at that one frequency not reveal the delay? Answer: \(-2\pi \times 50 \times 0.02 = -2\pi\) rad, which wraps to 0, exactly as for no delay. One wrapped phase only fixes \(\tau\) up to multiples of \(1/f\); the slope across many frequencies (unwrapped) is needed.
  5. A rebuilt signal uses the magnitude of a rectangular pulse and the phase of a damped chirp. Which original does it resemble, and what does that say about phase? Answer: the chirp (\(r_B\) = 0.64 against \(r_A\) = −0.18). Where edges and oscillations occur in time is encoded in the phase, so structure follows the phase.

Common Misconceptions

"The magnitude spectrum describes the signal; the phase is a minor detail." View A keeps \(|X|\) fixed while the peak moves between 1.44 and 1.83, and view C shows that a magnitude combined with someone else's phase looks like that someone else. With zero phase every signal collapses to a shape centred on \(t = 0\).

"Every jump in a phase plot is a \(2\pi\) wrap." Wrapping jumps are \(2\pi\) and disappear when you unwrap. The rectangular pulse in view B also has jumps of \(\pi\) where its spectrum changes sign; unwrapping cannot remove them, and they are not part of the delay.

References

  1. Discrete Fourier transform - Wikipedia - the DFT used in views B and C, including its circular shift property
  2. Linear phase - Wikipedia - why a phase proportional to frequency is a pure delay that preserves waveform shape
  3. Group delay and phase delay - Wikipedia - delay as minus the slope of the phase, the quantity read from view B
  4. Phase unwrapping - Wikipedia - removing \(2\pi\) jumps and the ambiguities that remain
  5. Crest factor - Wikipedia - peak-to-RMS ratio, which changes with phase in view A while the RMS does not
  6. The Scientist and Engineer's Guide to Digital Signal Processing - Steven W. Smith - free online textbook with chapters on the DFT, polar notation and phase