# Visualizing Eigenvectors with GlowScript

**Posted:**April 17, 2017

**Filed under:**Motivations |

**Tags:**computation, eigenvectors, GlowScript, introductory physics, linear algebra, programming, visualization, VPython Leave a comment

I owe this post entirely to my mathematics colleague Ethan Smith and his recent work on visualizing eigenvectors in a plane. This work is based in turn on the paper by Schoenfeld. I’ve taken the visualization to 3D with the help of GlowScript and Trinket.

I was instantly interested in this project becuase I’m looking for ways to bring concepts from linear algebra (e.g. matrices, eigenvalues, tensors, etc.) into introductory claculus-based physics courses. I want to do this in a way that fosters the need for modern computation and visualization of geometric properties.

The concept here is very simple. You create a three dimensional distribution of unit vectors. I chose a spherically symmetric distribution. There’s really no necessity to use unit vectors as far as I can see; it just makes the numbers easier to manage. You then operate on each of these vectors with a linear transformation, represented by a matrix multiplication. The transformed vectors are visualized with arrows with their tails at the tips of the unit vectors. The transformation’s eigenvectors are immediately visible by inspection as the vectors represented by arrows collinear with the arrows representing the original unit vectors.

Unfortunately, I can’t embed trinkets in this blog, so I’ll have to make do by providing a link. When you click the link below, the trinket will open in a new browser window. You should see the GlowScript/VPython code on the left and the visualization on the right. The original unit vectors are white and the transformed vectors are blue (arbitrary color choices). You’re looking for the blue arrows that are collinear with white arrows. Those are the transformation’s eigenvectors. You can experiment with changing the number of unit vectors. More importantly, you’re encouraged to experiment with different transformation to see the effects of different eigenvalues. (I will come back later and include a screenshot here.)

Click this link to open the eigenpictures trinket.

The default matrix has eigenvalues of 1, 2, and 1 and the visualization makes spotting the eigenvectors quite simple.

I think this could have applications in introductory physics for visualizing inertia tensors. They can be represented as ellipsoids whose axes are the eigenvalues. I look forward to exploring this idea, and I thank Ethan Smith for showing me this.