Phasor Lab

Computer Systems Modelling · Section 5.1 · Interactive lab

Sinusoids from a rotating vector

A sinusoidal carrier is the shadow of a rotating vector on the X-axis. This lab builds up from that picture to the phasor notation cejθ and to the way the same objects are written in Python, where 1j is the rotation operator j.

How it works and what to try

How it works: In four tabs. (1) The rotating vector: a disk turns with period T; its projection on the X-axis traces out the carrier of Figure 5.1, and you can drag the vector by hand. (2) j as a rotation: multiply by j, by −1, or take the conjugate, and watch the vector turn or reflect. (3) Euler’s formula: edit a point in rectangular form a + jb or phasor form c ejθ and see the other follow, with buttons for Examples 5.1 and 5.2. (4) Negative frequency: two phasors turn in opposite directions, and their sum stays on the real axis (Equations 5.5 and 5.6). Each tab shows the matching Python code, with its output.

Try this: Reverse the direction of rotation and notice that the cosine does not change, but the sine does. Press Multiply by j four times and see where the vector ends up. Convert −3 + j4 to phasor form and work out why atan(b/a) gives the wrong angle. Each exercise has a hidden answer.

Section, figure, example and equation numbers refer to Chapter 5 of S. Keshav, Mathematical Foundations of Computer Networking, Addison-Wesley, 2012.

1.00
2.00
Direction of rotation
ω = ±2π/T (rad/s)
—
θ = ωt (rad)
—
c cos θ
—
c sin θ
—

The carrier as a phasor

θ = 2πtT = ωt
signal(t) = c cos θ = Re(c ejωt)

Drag the dot on the rim to set θ by hand. The animation pauses while you drag.

The diska unit-radius disk turning with period T; the orange line is the projection on the X-axis

Below the disk, the projection is recorded as time runs downward: the newest value is at the top. The trace is the carrier turned on its side.

t = 0.00 s
The carrier, as in Figure 5.1signal against time over four periods
Re(c ejωt) = c cos ωt
Python · the value at this instant

    
Python · the whole carrier (Figure 5.1)

    

What to notice

The orange projection moves back and forth along the X-axis, and its record over time is a cosine with period T. Changing c changes the amplitude; changing T changes how quickly the vector turns. Reversing the direction of rotation does not change the cosine at all, because cos(−θ) = cos θ. Turn on the Y projection to see that it is the sine that changes sign. This is why a clockwise rotation needs its own name, a negative frequency, which is the subject of the last tab.

In Python, the letter j written after a number, as in 1j, is the imaginary unit. Python follows the engineering convention described in the footnote to Section 5.1.2, so the code reads almost exactly like the mathematics.