# 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.

# Matter & Interactions II, Weeks 13 and 14

**Posted:**April 13, 2017

**Filed under:**Course Log, Goals, Motivations |

**Tags:**Ampére's law, circulation, electromagnetic theory, flux, Gauss's law, introductory physics, line integral, Maxwell's equations, surface integral, vector calculus Leave a comment

I’m combining two weeks in this post.

The first week, we dealt with magnetic forces. One thing that I have never thought much about is the fact that the quantity is effectively an electric field, but one that depends on velocity. When velocity is involved, reference frames are involved, and that of course means Einstein is talking to us again. M&I addresses the fact that what we detect as an electric field and/or a magnetic field depends on our reference frame. This is fundamental material that I feel should be included in every introductory electromagnetic theory course. There’s really no good reason to omit it given that special relativity is a foundation of all contemporary physics. It’s sad to think that beginning next fall, our students won’t be exposed to this material any more.

The second week gets us into chapter 21, which presents Gauss’s law and Ampére’s law. There are many fine points and details to present here. I’ll try to list as many as I can think of.

- I use the words
*pierciness*,*flowiness*,*spreadingoutness*, and*swirliness*to introduce the concepts of flux, circulation, divergence, and curl respectively. - We have the term
*flux*for the quantity given by surface integrals, but we rarely if ever see the term*circulation*for line integrals. I recommend introducing the term, primarly because it forms the basis for the definition of curl. - The distinction between an open surface and a closed surface is very important.
- I, like M&I, prefer to write vector area as rather than because it allows for introducing a “sneaky one” into the calculation of flux that lets a dot product become a product of scalars when the field is parallel to the surface’s unit normal:
- Similarly, I like an element of vector length, at least for electromagnetic theory, as rather than (the is supposed to be bold but it doesn’t look bold to me). I don’t think I have ever seen this notation in an introductory course before, but I like it because students have seen unit tangents in calculus and this notation closely parallels that for vector area as described above. Plus, it also allows for a “sneaky one” into the calculation of circulation when the field is parallel to the path’s unit tangent::
- After this chapter, we can finally write Maxwell’s equations for the first time. I show them as both integral equations and as differential equations. One of my usual final exam questions is to write each of the four equations as both an integral equation and a differential equation and to provide a one sentence interpretation of each form of each equation.

That’s about it for these two chapters. I thought there was something else I wanted to talk about, but it seems to have escaped me and I’ll update this post if and when I remember it.

Feedback welcome as always.

# Vector Formalism in Introductory Physics I: Taking the Magnitude of Both Sides

**Posted:**April 11, 2017

**Filed under:**Goals, Motivations, Understanding |

**Tags:**coordinate free, dot product, geometry, introductory physics, vector algebra, vector analysis Leave a comment

**TL;DR: I don’t like the way vectors are presented in calculus-based and algebra-based introductory physics. I think a more formal approach is warranted. This post addresses the problem of taking the magnitude of both sides of simple vector equations. If you want the details, read on.**

This is the first post in a new series in which I will present a more formal approach to vectors in introductory physics. It will not have the same flavor as my recently begun series on angular quantities; that series serves a rather different purpose. However, there may be some slight overlap between the two series if it is appropriate.

I am also using this series to commit to paper (screen, really) some thoughts and ideas I have had for some time with the hope of turning them into papers for submission to The Physics Teacher. I’d appreciate any feedback on how useful this may be to the community.

To begin with, I want to address issues in the algebraic manipulation of vectors with an emphasis on coordinate-free methods. I feel that in current introductory physics courses, vectors are not exploited to their full potential. Instead of learning coordinate-free methods, students almost always learn to manipulate coordinate representations of vectors in orthonormal, Cartesian coordinate systems and I think that is unfortunate because it doesn’t always convey the physics in a powerful way. **Physics is independent of one’s choice of coordinate system, and I think students should learn to manipulate vectors in a similar way. **

Let’s begin by looking at a presumably simple vector equation:

The object is to solve for given . Don’t be fooled; it’s more difficult than it looks. In my experience, students invariably try to divide both sides by but of course this won’t work because vector division isn’t defined in Gibbsian vector analysis. **Don’t let students get away with this if they try it!** The reasons for not defining vector division will be the topic of a future post.

**(UPDATE:** Mathematics colleague Drew Lewis asked about solving this equation by combining like terms and factoring, leading to and then to . This is a perfectly valid way of solving the equation and it completely avoids the “division by a vector” issue. I want to call attention to that issue though, because when I show students this problem, they always (at least in my experience) try to solve it by dividing. Also, in future posts I will demonstrate how to solve other kinds of vector equations that must be solved by manipulating both dot products and cross products, each of which carries different geometric information, and I want to get students used to seeing and manipulating dot products. Thanks for asking Drew!)

One could simply say to “take the absolute value of both sides” like this:

but this is problematic for two reasons. First, it destroys the sign on the righthand side. Second, a vector doesn’t have an absolute value because it’s not a number. Vectors have magnitude, not absolute value, which is an entirely different concept from that of absolute value and warrants separate consideration and a separate symbol.

We need to do something to each side to turn it into a scalar because we can divide by a scalar. Let’s try taking the dot product of both sides with the same vector, , and proceed as follows:

This is a better way to proceed. It’s formal, and indeed even pedantic, but I dare say it’s the best way to go if one wants to include dot products. Of course in this simple example, one can see the solution by inspection, but my goals here are to get students to stop thinking about the concept of dividing by a vector and to manipulate vectors algebraically without referring to a coordinate system.

Let’s now look at another example with a different vector on each side of the equation.

Once again the object is to solve for given and . Note that solving for either or is obviously trivial so I won’t address it; it’s simply a matter of scalar division. Solving for is more challenging because we must again suppress the urge to divide by a vector. I will show two possible solutions. Make sure you understand what’s being done in each step.

We get two solutions, and they are geometrically opposite each other; that’s the physical implication of the signs. (I suppose we could argue over whether or not to just take the principal square root, but I don’t think we should do that here because it would throw away potentially useful geometric information.) We can find a cleaner solution that accounts for this. Consider the following solution which exploits the concepts of “factoring” a vector into a magnitude and a direction and the properties of the dot product.

See the geometry? It’s in the factor . If and are parallel, this factor is and if they are antiparallel it is . Convince yourself that those are the only two options in this case. (HINT: Show that each vector’s direction is a scalar multiple of the other vector’s direction.) This solution won’t work if the two vectors aren’t collinear. If we’re solving for then both vectors are assumed given and we know their relative geometry.

Let’s look at another example from first semester mechanics, Newton’s law of gravitation,

where and should be read as “the position of 1 relative to 2.” Let’s “take the magnitude of both sides” by first writing in terms of its magnitude and direction, dotting each side with a vector, and dividing both sides by the resulting common factor.

Okay, this isn’t an Earth-shattering result becuase we knew in advance it has to be the answer, but my point is how we formally went about getting this answer. More specifically, the point is how we went about it without dividing by a vector.

Let’s now consider a final example from introductory electromagnetic theory, and this was the example that got me thinking about this entire process of “taking the magnitude of both sides” about a year ago. It’s the expression for the electric force experienced by a charged particle in the presence of an electric field (obviously not its own electric field).

That one vector is a scalar multiple of another means the two must be collinear, so they must either be parallel or antiparallel. An issue here is that is a signed quantity. Again, we have a choice about which vector with which to dot both sides; we could use or we could use . If we use the former, we will eventually need to take the square root of the square of a signed quantity, which may lead us astray. Therefore, I suggest using the latter.

This may look overly complicated, but it’s quite logical, and it reflects goemetry. If is negative, then the dot product will also be negative and the entire quantity will be positive. If is positive, then the dot product will also be positive and again the entire quantity will be positive. Geometry rescues us again, as it should in physics. We can also rearrange this expression to solve for either or with the sign of properly accounted for by the dot product. By the way, and can’t be orthogonal becuase then their dot product would vanish and the above expression would blow up. Geometry and symmetry, particularly the latter, preclude this from happening.

In summary, “taking the magnitude of both sides” of a simple vector equation presents some challenges that are mitigated by exploiting geometry, something that is neglected in introductory calculus-based and algebra-based physics courses. I suggest we try to overcome this by showing students how to formally manipulate such equations. One advantage of doing this is students will see how vector algebra works in more detail than usual. Another advantage is that students will learn to exploit geometry in the absence of coordinate systems, which is one of the original purposes of using vectors after all.

Do you think this would make a good paper for The Physics Teacher? Feedback welcome!