Visualizing the Eigenvectors of a Rotation

posted by Craig Gidney on October 15, 2013

In this post: a visual understanding of complex eigenvectors.

Motivation

Did you know rotation can be thought of as a type of scaling?

I’ve been trying to fix the fact that my knowledge of quantum computing is not well grounded. To that end, I’ve been slowly working my way through the first couple chapters of Quantum Computation and Quantum Information. Basically that just means I’m brushing up on linear algebra. More specifically, linear algebra involving complex numbers.

Linear algebra involving complex numbers is surprisingly similar to “normal” linear algebra, with a few tweaks. For example, the inner product is no longer just the dot product. You have to take the complex complement of the second vector first. So \left< 1, i \right> is orthogonal to \left< i, 1 \right> because \left< 1, i \right> \cdot \overline{\left< i, 1 \right>} = \left< 1, i \right> \cdot \left< -i, 1 \right> = 1 \cdot -i + i \cdot 1 = -i+i = 0.

Another difference is that rotating a vector can be broken down into scaling its components in a particular basis.

Rotating vs Scaling

The effect of an operation on a particular vector is sometimes very simple. When an operation does nothing except scale a vector by a constant factor, that vector is called an eigenvector of the operation. In “normal” linear algebra, without complex numbers, rotations have no eigenvectors (not counting 0° and 180° rotations). Basically, everything gets twisted instead of scaled. (Go ahead, try to find one.)

It turns out that once you allow complex numbers into your linear algebra, rotations do have eigenvectors. When you try to turn these vectors, you end up scaling them instead.

This idea is counter-intuitive, so I went searching for an explanation. Turns out someone already asked about it on the mathematics stack exchange: Geometric interpretation for complex eigenvectors of a 2×2 rotation matrix. The top answer is really good, except… it’s an algebraic interpretation, not geometric. I understand it… but when I read the title of the question I was hoping for a picture-type answer.

I know that making things complex doubles the number of dimensions, and that means even picturing basic things like how \left< 1, i \right> is orthogonal to \left< i, 1 \right> requires the intractable feat of visualizing 4 dimensional space. So we can’t picture things the obvious way. But surely there’s some visual way to explain these eigenvectors?

Oh wait, I already have just the right tool for the job.

Phased Bar Charts

I’ve thought about how to represent complex vector spaces and operations in the past, when writing my explanations of Grover’s quantum search algorithm and quantum pseudo-telepathy. One idea I came up with, that didn’t work at the time for reasons that will become obvious, is what I call a “phased bar chart”.

A phased bar chart is like a normal bar chart, but each bar represents a complex number instead of a real number. The length of a bar is still the magnitude of the number, but you rotate the bars to also show the phase. With some careful layout to ensure bars don’t overlap, you end up with what looks like bars shooting out of a convex polygon.

Here’s how the components of the vector \left< 1,i,(i-1)/3 \right> are represented as a phased bar chart:

Representation of Vector

As you can see, the first component is represented by the blue bar labelled c_1. It points to the right because c_1 = 1 and the positive real direction in the complex plane is rightward. Similarly, the red bar labelled c_2 points upward because the imaginary axis increases in that direction and the second component is +i. Finally, the yellow bar labelled c_3 represents the third component of the vector, and is diagonal because c_3=(i-1)/3 is not purely real or imaginary.

One strength of phased bar charts is that, when animated, they demonstrate the effects of scaling very clearly. For example, here’s what happens as we scale \left< 1,i,(i-1)/3 \right>:

Real Scaling

Even if I hadn’t said what operation was being animated in the above diagram, it’s trivial to see that it’s scaling. The scaling of each bar perfectly matches the scaling of the overall vector.

We’re not just limited to scaling by a real factor. We can scale by i, and this will also have a simple visual effect on the diagram: it will rotate. Here’s what happens as we scale our vector by values from the complex unit circle:

Complex scaling looks like rotation

Keep in mind that the rotation you’re seeing is not between the components of the vector, but within each component’s phase. The vector is not turning, its components are phasing.

In general, scaling by a complex factor will scale and rotate a phased bar chart. The scaling is proportional to the magnitude of the scaling factor, and the rotation is proportional to the phase (as you can see above).

So scaling by a complex factor has simple, easily recognizable effects on a phased bar chart. What about other operations? Well… not so clear. For example, can you guess what operation is being shown by the following animation?

Unspecified operation, not scaling, looks weird

I have no idea what’s going on in the above animation. I know what the operation is, and it’s still confusing!

Phased bar charts are not a good way to convey a sense of what an arbitrary operation is doing to a complex vector.

But. We don’t need to be able to recognize any old operation. We only care about recognizing scaling by a complex factor, because that’s the only thing that happens to the eigenvectors of an operation. When we animate what happens to an eigenvector, the chart will just scale and rotate. When we animate other vectors, the chart will wiggle and skip and warp. So we can use the animation to recognize eigenvectors!

Charting Rotation

The matrix that rotates a 2-dimensional vector by \theta radians is \left[ \begin{array}{cc} cos(\theta) & sin(\theta) \\ -sin(\theta) & cos(\theta) \end{array} \right]. Let’s see how things animate as we increase \theta and show the result of multiplying some test vectors by the rotation matrix.

The obvious place to start is with the vector \left< 1, 0 \right>. Rotating it through the range of angles and charting the outputs results in this animation:

Rotating [1,0] looks sinusoidal but not like rotation

The vector is turning, but the diagram is not scaling/rotating. The bars are individually scaling based on a sinusoidal motion, which is promising since circular motions are made up of sinusoidal motions along each axis, but nevertheless \left< 1, 0 \right> is not an eigenvector.

The next obvious vector to test is \left< 0, 1 \right>:

Rotating [0,1] also looks sinusoidal but not like rotation

Just the same sinusoidal motion again, although it has shifted by a quarter period. I guess I was foolishly hoping that switching to the other component would give us some vertical motion.

Vertical corresponds to imaginary, so let’s try the vector \left< i, 0 \right> now:

Rotating [i,0] just makes things vertical

Aha, there’s that vertical motion. Real components are moving horizontally, imaginary components are moving vertically, and the movement is sinusoidal…

I bet combining the real and imaginary bits is going to look circular. Let’s try \left< 1, i \right>:

Rotating [1,i] shows scaling. It's an eigen vector

Well. Hello, Mr. Eigenvector, how are you doing today? Rotating counter-clockwise? How interesting!

I bet the other eigenvector from the StackExchange question rotates in the opposite direction. Trying \left< 1, -i \right>:

Rotating [1,-i] shows scaling. It's an eigen vector

Yup, clockwise instead of counter-clockwise.

I think I almost intuitively understand what’s happening, now. The vector rotation between the components is being turned into phase rotation within the components.

The two eigenvectors form a basis. You can rewrite any 2-dimensional complex vector in terms of that basis, and thus interpret rotation as scaling/phasing the rewritten components. The specific scaling factors depend on the amount of rotation, and changing the scaling factors will change how much the vector rotates. So rotation is, in a sense, a type of scaling.

Summary

Phased bar charts scale and rotate without distorting when, and only when, the operation being animated is being applied to one of its eigenvectors. This allows us to visually recognize eigenvectors.

The complex eigenvectors of rotation change phase (a type of complex scaling) when you rotate them, instead of turning.

Discuss on Reddit

My Twitter: @CraigGidney

  • Abderrahmane_TJ

    How does one make such cool charts ? :D

    • CraigGidney

      I do it with code. Ugly, hacky code filled with magic numbers, no comments and using concepts that I experimented with but that only really half worked out. The git repo is called AnimatronTheTerrible. I emphasize that the Terrible is not a joke. I did not write this code for other people to read.

      The methods that made the charts in these posts are in the Animations/SuperpositionVisualization.cs file.

      If you want an animation tool based on code intended for other people to use, check out Steven Wittens’ MathBox.


Twisted Oak Studios offers consulting and development on high-tech interactive projects. Check out our portfolio, or Give us a shout if you have anything you think some really rad engineers should help you with.

Archive

More interesting posts (3 of 12 articles)

Or check out our Portfolio.