## Visualizing the Eigenvectors of a Rotation

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 is orthogonal to because .

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 is orthogonal to 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 are represented as a phased bar chart:

As you can see, the first component is represented by the blue bar labelled . It points to the right because and the positive real direction in the complex plane is rightward. Similarly, the red bar labelled points upward because the imaginary axis increases in that direction and the second component is . Finally, the yellow bar labelled represents the third component of the vector, and is diagonal because 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 :

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 , 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:

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?

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 radians is . Let’s see how things animate as we increase and show the result of multiplying some test vectors by the rotation matrix.

The obvious place to start is with the vector . Rotating it through the range of angles and charting the outputs results in this animation:

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 is not an eigenvector.

The next obvious vector to test is :

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 now:

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 :

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 :

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

CraigGidney

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

- strilanc
- What Quantum Computers Do Faster, with Caveats
- Naming Things: Fail-Useful
- Detecting Simple Cycles Forming, Faster
- Third Party Bit Commitment
- Angular Velocity is Simple
- Collection Equality is Hard
- Deadlocks in Practice: Don’t Hold Locks While Notifying
- Brute Force Parallelization
- A Year’s Worth of Opinions about Objective-C
- Referencing Substrings Faster, without Leaking Memory
- Not Crying Over Old Code
- Exploring Universal Ternary Gates
- Impractical Experiments #2: Securing Peer to Peer Fog of War against Map Hacks
- Achieving Exponential Slowdown by Enumerating Twice
- Using Immortality to Kill Accidental Callback Cycles
- Cancellation Tokens (and Collapsing Futures) for Objective-C
- Visualizing the Eigenvectors of a Rotation
- Collapsing Futures in Objective-C
- Bug Hunting #1: Garbled Audio from End to End
- Impractical Experiments #1: Representing Numbers as Polynomials
- Implementing Quantum Pseudo-Telepathy
- Turn On Your Damn Warnings
- Big-O Made Trivial
- Unfathomable Bugs #7: The Broken Oven
- Solomonoff’s Mad Scientist
- Yearly Blogging Roundup #1
- What isn’t a Monad
- Searching a Sorted Matrix Faster
- How to Read Nested Ternary Operators
- Making Sublime Text 2 Jump to the Correct Line with Unity on OS X
- My Bug, My Bad #4: Reading Concurrently
- Whole API Testing with Reflection
- Optimizing a Parser Combinator into a memcpy
- Don’t Treat Paths Like Strings
- Breaking a Toy Hash Function
- Counting Iterators Lazily
- Unfathomable Bugs #6: Pretend Precision
- My Bug, My Bad #3: Accidentally Attacking WarCraft 3
- Collapsing Types vs Monads (followup)
- Collapsing Futures: Easy to Use, Hard to Represent
- Eventual Exceptions vs Programming in a Minimal Functional Style
- The Mystery of Flunf
- Explain it like I’m Five: The Socialist Millionaire Problem and Secure Multi-Party Computation
- Computer Science Blows My Mind
- A visit to Execution Labs in Montréal
- Transmuting Dice, Conserving Entropy
- Rule of Thumb: Ask for the Clock
- Rule of Thumb: Use Purposefully Weakened Methods
- Rule of thumb: Preconditions Should be Checked Explicitly
- Intersecting Linked Lists Faster
- Mouse Path Smoothing for Jack Lumber
- My Bug, My Bad #2: Sunk by Float
- Repeat Yourself Differently
- Grover’s Quantum Search Algorithm
- Followup to Non-Nullable Types vs C#
- Optimizing Just in Time with Expression Trees
- When One-Way Latency Doesn’t Matter
- Determining exactly if/when/where a moving line intersected a moving point
- Emulating Actors in C# with Async/Await
- Making an immutable queue with guaranteed constant time operations
- Improving Checked Exceptions
- Perishable Collections: The Benefits of Removal-by-Lifetime
- Decoupling shared control
- Decoupling inlined UI code
- Linq to Collections: Beyond IEnumerable<T>
- Publish your .Net library as a NuGet package
- When null is not enough: an option type for C#
- Unfathomable Bugs #5: Readonly or not
- Minkowski sums: examples
- My Bug, My Bad #1: Fractal Spheres
- Working around the brittle UI Virtualization in Windows 8
- Encapsulating Angles
- Unfathomable Bugs #4: Keys that aren’t
- How would I even use a monad (in C#)?
- Useful/Interesting Methods #1: Observable.WhenEach
- Unfathomable Bugs #3: Stringing you along
- Anonymous Implementation Classes – A Design Pattern for C#
- Tasks for ActionScript 3 – Improving on Event-Driven Programming
- Minkowski sums and differences
- Non-Nullable Types vs C#: Fixing the Billion Dollar Mistake
- Unfathomable Bugs #2: Slashing Out
- Script templates and base classes
- Unity font extraction
- Abusing “Phantom Types” to Encode List Lengths Into Their Type
- Constructive Criticism of the Reactive Extensions API
- Quaternions part 3
- Quaternions part 2
- Quaternions part 1
- Unfathomable Bugs #1: You can have things! You can have things IN things! You can have …
- Coroutines – More than you want to know
- Asset Bundle Helper
- The Visual Studio goes away
- .Net’s time traveling StopWatch
- Introducing Catalyst