Visualizing Eigenvectors with GlowScript

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.

 


Matter & Interactions II, Week 9

This week was a very short week consisting of only two days. We met as usual on Monday, but Tuesday was a “flip day” and ran as a Friday. This class doesn’t meet on Fridays so we only had one day this week, and we devoted it to tying up loose ends from chapter 17.

Next week, barring losing days to winter weather as I sit here and watch the forecast deteriorate, we will hit circuits the M&I way!

In an interesting development, I was informed by my coworker (a PhD physicist) that our department chair had approached him Tuesday morning to ask if he would like to take my calculus-based physics courses from me next year on the grounds that I’m not rigorous enough. Needless to say, I was shocked becuase the chair had not mentioned this to me and indeed has not spoken to me about it at all. Had my coworker not told me I would not have known.

My chair, a PhD chemist, seems to think that because M&I emphasizes computation over traditional labs, and that what labs we do are not as rigorous as chemistry labs, either M&I or I or perhaps both are not appropriate for our students and indeed may be causing them to be ill prepared for transfer to universities. Of course this is all nonsense, but my chair actually said to my face that she knows more about computation, theory, and experiment than I do and that labs must be done the “chemistry way” or they’re not valid. If this weren’t so disgustingly true, it would be mildly funny. It’s not funny. It’s true.

I don’t know what I’m going to do, but it’s clear both M&I and I are probably on our way out at my current instituion. My colleague (who by the way has no interest in teaching calculus-based physics) and I are both exploring numerous options, including leaving for another instiution.

 


My LaTeX Materials for Students

Beginning this semester, my physics (introductory calculus-based physics) class is using LaTeX for writing up solutions. Rather than installing TeX Live (MacTeX) on every machine, we’re using Overleaf because it seems to work on desktops, laptops, and tablets (at least as far as I can tell). I give students a ZIP file containing five files, each of which I will describe here.

  1. mandi.sty This is the most up-to-date build of the mandi package and is almost always more recent than the version availble on CTAN. Before pushing an update to CTAN, I like to give students a chance to use it and to make suggestions for corrections, better features, and so on.
  2. mandi.pdf This is the corresponding documentation to the latest mandi build.
  3. NnnnnnnnCCPxx.tex This is the file (the ONLY file) that students need to edit directly. The filename structure is as follows: Nnnnnnnn is the student’s last name with the first character capitalized, CC is a two digit chapter number (ostensibly keyed to Matter & Interactions but of course it could refer to any textbook), P indicates a problem solution and this character should never be changed, xx is a two digit problem number (again, ostensibly keyed to Matter & Interactions).
  4. NnnnnnnnCCPxx.py This is the (V)Python or GlowScript script intended to accompany a given problem. One of my goals is to deprecate the use of calculators in favor of doing things in (V)Python. I want to offload the computational aspects problem solving to (V)Python so students can focus on the reasoning behind the computations and number crunching. By the way, note that I wrote (V)Python because sometimes we don’t really need anything visual for computation and so plain Python suffices.
  5. NnnnnnnnCCPxxFigyy.pdf This just a sample image used to illustrate how to incorprate images. Note the naming convention with yy being a two digit figure number.

So in practice, students dump these files into a “master project” on Overleaf. They will then clone this “master project” each time they need to write up a new solution. They will name the new project according to our naming convention, and will modify the names of the .tex, .py, and .pdf file accordingly. Note that not every solution will require an image or diagram, and if one isn’t required they will just comment out, or remove entirely, the source code that incorporates a image.

One bad thing I see no way around is that students must manually update older projects to use the updated mandi files and this is time consuming; I don’t yet see a way around it though.

Another potential bottleneck is how students generate diagrams and images. Right now, I’m asking them to draw their diagrams and figures on paper with pencil and then photograph or scan them with their smartphone and do whatever is necessary to generate a PDF file. Then they can appropriately rename this file and include it in their project.

When I make updates to mandi, I compile the entire package from a single .dtx file using TeXShop and then I clean all the auxilliary files from the (pdf)LaTeX runs. I have a shell script (written in Bash) that I then launch from a Terminal that makes on-the-fly modifications to the mandi source files and prepares them for uploading to CTAN in a ZIP file. In the same run, the script also builds the Overleaf template ZIP file and copies it, the mandi CTAN build, and the new source files to a folder on Dropbox from which I can share things as necessary and have a secure backup in case something happens to my local machines.

My hope is that students will build a logically organized and easily searchable library of problem solutions, each of which is a standalone project. I’ll keep everyone posted on how this works. Students are already saying that knowing LaTeX is, or will be, a huge help for them when they transfer to a university.