I’ve been thinking a bit about spectra and singular values as I’ve been working on some ideas related to ecology and neuroscience, and I’ve decided to write up my musings. I’ve realized that I’ve never really sat down and thought about SVD, as I usually deal with Hermitian, anti-Hermitian, or orthogonal matrices which are all normal (so the singular vectors are just eigenvectors). In this post I’ll just go through some thoughts on ideas in linear algebra, and in a later post I may expand on the neuroscience and ecology ideas that got me started thinking about this.

Definitions

We’ll be talking about linear operators (matrices, in coordinates), which I’ll denote by boldface capital letters like . Vectors will be lower case bold , and scalars will just be normal “mathed” characters like .

Eigenvectors and Jordan form

I’ll start by first reviewing some basic things about eigenvectors. Given a linear operator , sending to , a vector is an eigenvector if we have , where is the associated eigenvalue. This definition is good enough for finite dimensional vector spaces. Otherwise, we can generalize the definition of eigenvalue to that of the spectrum of an operator, which is the collection of values such that is not invertible. Eigenvalues are always in the spectrum, but in infinite dimensional vector spaces we can get into funky situations where there are elements in the spectrum which don’t correspond to any eigenvectors.

However, we’ll stick to finite dimensional vector spaces for this post (over , for the pedants at home). In a finite dimensional vector space, there is always at least one eigenvalue. One way to see this is to think about the determinant of . This is a polynomial, so we know that we always have at least one root over the complex numbers. With each eigenvalue, there is associated at least one eigenvector.

If we have no degenerate eigenvalues (one unique eigenvalue for each dimension), then we are guaranteed to have an eigenbasis - a set of linearly independent eigenvectors which span our space. In the eigenbasis coordinate system, has a very simple form: it is diagonal with entries equal to the eigenvalues . This is the source of the power of eigenvalues and eigenvectors; they give us a coordinate system where the linear operator can be described as simply as possible, as independent multiplications as opposed to for a “typical” matrix. In many linear or near-linear dynamical systems, understanding the eigenmodes (dynamics in the eigenbasis) individually leads to direct understanding of the global dynamics.

However, if we have a degeneracy (repeated eigenvalues, ie multiple roots in the characteristic polynomial), then we are not guaranteed to have a complete eigenbasis. In the worst case scenario we are guaranteed a nested set of invariant subspaces. That is, we have some collection of vectors such that

where . More concretely, this means we can find a basis where is almost diagonal, possible with 1’s on the off diagonal. This is known as the Jordan canonical form, and the blocks look like

The non-diagonalizability is related to nilpotent elements - submatrices which are non-zero, but become zero when raised to some power. A simple example is the 3-d matrix

This matrix only has one eigenvalue (0) and one eigenvector (the first coordinate). It is already in Jordan form. We can compute its powers as

The matrix is evidently a shift operator. It becomes 0 after the 3rd power. (Note: in linear dynamical systems, operators like this set up dynamics linear in time as opposed to the exponential dynamics set up by eigenvectors normally. In the above example if coordinate 1 is position, coordinate 2 becomes speed and 3 acceleration).

Invariant subspaces and QR decomposition

While the eigenbasis decomposition is the most common and useful way to characterize matrices, it is far from the only informative one. We will talk briefly about converting matrices to triangular forms, with an eye towards talking about singular value decomposition in the next section.

For any finite dimensional linear operator (matrix), we can find some basis in which it is upper triangular. In some sense we already know this because of the Jordan canonical form mentioned in the previous section; however we can go through an alternative calculation which gets us a different decomposition.

What kind of operator does an upper triangular matrix represent? In terms of the basis coordinates, the first coordinate maps to a subspace spanned by the first coordinate, the first two coordinates map to a subspace spanned by the first two, and so on and so forth. In this way, there are a nested set of invariant subspaces - linear subspaces that map onto themselves.

How can we construct such a set of nested invariant subspaces? One way is to construct one inductively. Suppose that we have an invariant subspace of dimension . We can find one of dimension in the following way. Let be the orthogonal projection onto our dimensional invariant subspace . That is, on it is the identity; orthogonal vectors map to 0. Then consider

This linear map outputs onto the orthogonal subspace . Therefore, restricted to it is a map from that subspace onto itself. It has some eigenvector . While is an eigenvector of , it is not an eigenvector of ; however, it has no other projection onto . Therefore, maps onto itself; we now have a dimensional subspace!

Our base case is a 1-dimensional invariant subspace; that is, an eigenvector. We already know that each linear operator has an eigenvector; therefore we are done. We’ve proven that a nested set of invariant subspaces exists.

In fact, we’ve done more. What we’ve done is shown that this series of invariant subspaces are orthogonal to each other. We have proven the existence of a decomposition

where is upper triangular, and is a unitary matrix (generalized rotation for complex vector spaces, ). Here is the adjoint (transpose + complex conjugate).

Related to this decomposition is the QR decomposition where can be written as - where the first matrix is orthogonal and the second is upper triangular. While our above decomposition scheme dependeded on the eigenvectors chosen, the QR decomposition is unique if is invertible, and we choose the diagonal elements of to be positive and ordered. Note that RQ, LQ, and QL decompositions also exist (L being lower triangular).

Singular value decomposition

In the above decompositions, we’ve secretly added a hidden structure: an inner product. Unitary matrices (and even the adjoint) implicitly assume that some inner product exists. After all, a rotation is an operator that leaves lengths invariant!

The most commonly used type of unitary transformation of a matrix is the singular value decomposition (SVD). We decompose our matrix as

where and are unitary, and is diagonal. In order to make the decomposition unique up to complex phases, one picks the to be positive and ordered (which can be accomplished by permutation and multiplying phases into the unitary matrices). The columns of are the right singular vectors and the columns of are the left singular vectors.

There are two ways to think about SVD, and the singular values themselves. One is as solutions to the optimization problem

where and are constrained to be fixed length. The singular values are the (local) minima of this constrained optimization; the pairs of vectors and give us the sets of left and right singular vectors respectively. These vectors obey the equations

If we pick the pair that gives us the maximal value, we can “shave it off” from the space: we know that inputting in gets us an output proportional to . However, if we have an input orthogonal to , its output will be orthogonal to by the second equation. Therefore we can take one dimension out of the input space and one out of the output space; we can iterate and construct the SVD as defined above.

Note that this kind of “optimization” definition nets us eigenvectors and eigenvalues when is symmetric, and we compute . This optimization formulation correctly generalizes to the case where the matrices are not symmetric.

Another way to get the singular values and vectors is to consider the matrices and . These are both Hermitian matrices (generalization of symmetric to complex valued). Hermitian matrices all have a complete, orthogonal eigenbasis with real eigenvalues. If we cheat and plug in the SVD form of into each of the formulae we get

and similarly

Therefore, the singular vectors are the eigenvectors of the two product matrices, and the singular values are the (positive) square roots of the eigenvalues of the two operators. (As a bonus note, these formulae tell us that for real , the singular vectors are real as well.)

Features of SVD and applications

There are a few important notes to make about SVD. The first is that SVD is very coordinate dependent. It depends on the (often implicit) choice of an inner product on our space, from which notions of orthogonality can be defined (and unitary matrices/transposes). The SVD is invariant under rotations (which don’t change the inner product) but not under non-orthogonal transformations (which correlate coordinates).

The second is a related point: the singular values are in general NOT the same as the eigenvalues, even in magnitude! As an example, consider the matrix

It has one degenerate eigenvalue . Now consider ; we have

If the eigenvalues were matched to the singular values, this matrix would have eigenvalues 1 and 1. However, its trace is 3; therefore its singular values and eigenvalues don’t match! More on which values matter later.

Also note that SVD can be applied to non-square matrices. In this case, is a square matrix with dimensions of the input, is the same for the output, and has the same dimensions as - and is diagonal or 0 (rectangular diagonal matrix). The number of singular values is the minimum of the dimensions of - the structure fundamentally can only have the dimensionality of the simplest vector space involved!

The singular values and eigenvalues are only the same when the matrix is normal - that is, it has an orthogonal eigenbasis. In this case . In fact, thinking about singular values gives us another way to characterize normal dynamics: an operator is normal if and only if

In other words, normal operators commute with their transposes! We prove this quite simply; the two products above can be used to get the and the , and if the singular vectors are the same, the matrices from which they are derived should be the same too.

All of these points come up when we use SVD in the “real world”. The most common useage of singular value decomposition is to analyze and reduce the dimensionality of data. Consider a data matrix constructed by “gluing together” data (column) vectors :

The right singular vectors give some sense of the correlations between different data elements. The left vectors give a basis over the data space. To reduce the dimensionality of data while preserving the structure, we can project the data onto only the left singular vectors which correspond to the largest singular values.

What structure are we preserving? Recall that the are the eigenvectors of . In our data matrix, the th entry of this matrix corresponds to

If the mean is subtracted out of our data, this is the covariance between coordinates and ! Therefore, the give us an ordered basis which contributes to the covariance. Projecting our data into some subset of the then preserves the covariance structure, while reducing dimensionality. This is the idea behind the popular dimensionality reduction technique PCA. The eigenvectors are called principal components (PCs). PCA is the appropriate thing to do when Gaussian distributions are involved, but is surprisingly useful in situations where that is not the case.

Our understanding of SVD tells us a few things about PCA. First, it is rotationally invariant. If we multiply our data by any unitary matrix, the PCA will basically be the same; PCs will be in direct 1-1 correspondence. However, any non-unitary linear transformation will change the structure of the PCs. The principal values will be different, and the PCs won’t map to each other 1-1. This is just for arbitrary linear transforms! Non-linear transforms will be even less related. That’s why if you’re doing PCA on data which isn’t Gaussian distributed, it may be worth randomly transforming the data, doing PCA, and seeing if the conclusions you draw are the same.

Normal vs. non-normal dynamics

We conclude with an example of the qualitative differences between understanding things from the singular value picture versus the eigenvalue decomposition. I may expand this in a later post with some examples from neuroscience and ecology modelling which inspired me to revisit my understanding of matrix decomposition.

Consider a linear dynamical system with the equation

Let be some fixed vector. We want to ask: when can perturbations in the direction not affect the dynamics, while the component is present at late times in the dynamics of ?

In general, we can solve linear dynamical systems by diagonalizing , and solving the resulting uncoupled system of equations. (We won’t deal with the case of degeneracy here.) Let for diagonal . Let . Then we have

We can use this basis to answer our question.

Consider first the case where is normal. Then, in the coordinate system of the , the inner product is just the standard inner product. If does not affect the dynamics, that means that does not project much onto components of which have large . Let ; then we have

which is given by

We know this is small since does not project much onto the which matter; therefore does not play into the dynamics much.

However, what happens if is not normal? Then we can arrive at our desired behavior, which we can see in one of two ways. First, suppose that has a large projection onto some left singular vector but is uncorrelated with the right singular vectors . Then

This explanation works, but is a bit annoying since it’s not in terms of the eigenbasis - which gives us a complete understanding of the dynamics. Here’s an alternative explanation.

Suppose again that is non-normal. Suppose now that is a zero eigenvector of . That is, it doesn’t contribute at all to the dynamics. Now when we calculate , we have

Now, even though is an eigenvector of (ie, a coordinate basis vector in the coordinates), the inner products are no longer compatible between the bases. The inner product is defined by the matrix , and now induces correlations between the different eigenmodes! Therefore even though has literally 0 dynamical contribution, projecting onto in the original space still gets us signal.

Here we arrive at an interesting feature of non-normal dynamics: the input-output behavior is not symmetric as it is for normal dynamics. In other words, coordinates which are nice for understanding dynamics don’t play nicely with the inner product. This is not important when there is symmetry up to linear transformations in the problem; one can then switch bases at will. However, when there is a particular basis with meaning (ie, the basis of neuron activities or species abundances), or when the noise characteristics are known in a particular basis (ie the basis with uncorrelated noise), then the distinction between normal and non-normal dynamics truly matters.

I won’t go into this now, but the question of normality of dynamics may be important for modelling efforts in both theoretical neuroscience and theoretical ecology. I hope to expand on this in a later post, when I have thought a bit more about how these things apply.