Magnitude Phase From Complex Bin
Run the Magnitude Phase From Complex Bin MicroSim Fullscreen
You can include this MicroSim on your website using the following iframe:
1 2 | |
About This MicroSim
Every FFT output bin is a complex number, and it carries two independent pieces of information:
Magnitude is how much of that frequency is present. It is the length of the vector.
Phase is where in its cycle that frequency started. It is the angle of the vector.
Drag the sliders and watch both change together. The default values, 6 and 8, give a magnitude of exactly 10 — a scaled 3-4-5 triangle, so you can check the square root by hand.
Why atan2 and Not atan
The formula is atan2(im, re), taking two arguments, not
atan(im / re).
Plain atan cannot tell the difference between \((6, 8)\) and \((-6, -8)\) — the
ratio is the same, so it returns the same angle for points in opposite
quadrants. atan2 sees the signs separately and returns the correct angle over
the full circle.
Try it: set re = 6, im = 8 and note the phase. Now set re = -6, im = -8. The
magnitude is identical, but the phase differs by π. Using plain atan here is a
real and easy bug to write.
What a Spectrum Plot Throws Away
Almost every spectrum display you will build in this course shows magnitude only. Phase is computed, then discarded.
That is usually the right call — the ear is largely insensitive to absolute phase, and a magnitude plot is what looks like a spectrum. But it is worth knowing that half of each bin's information is being dropped, and that anything requiring reconstruction, filtering, or time alignment needs the phase back.
How to Use
- At the defaults, verify magnitude by hand: \(\sqrt{36 + 64} = \sqrt{100} = 10\).
- Set im = 0. The vector lies flat along the real axis; phase is 0.
- Set re = 0, im positive. Phase is π/2 — straight up.
- Move both sliders to negative values and watch the phase move into the third quadrant. Confirm the magnitude is unaffected by the signs.
- Find two different (re, im) pairs with the same magnitude but different phase.
Lesson Plan
Grade Level
Undergraduate (college junior/senior)
Duration
10 minutes
Prerequisites
- Complex numbers in rectangular form
- The Pythagorean theorem
Learning Objective
Students will be able to calculate magnitude and phase from a bin's real and imaginary parts, and demonstrate the connection between the complex-plane point and both formulas.
Activities
- Hand-check (3 min): Students compute magnitude and phase for (3, 4) and verify against the readout.
- Quadrant test (4 min): Students compare (6, 8) against (-6, -8) and
explain why
atanalone would be wrong. - Same magnitude, different phase (3 min): Students find three pairs with magnitude 10 and record their phases.
Assessment
Ask: "A bin reads re = -5, im = 5. What are its magnitude and phase in degrees,
and what would atan(im/re) have returned instead?" (7.07 and 135°; atan gives
-45°.)
Related Resources
References
- atan2 — why the two-argument form is required.
- Complex number — the polar form these two quantities constitute.