# thinking

Name: Tyler
Location: Mountain View, California, United States

thinking := [life, games, movies, philosophy, math, coding, pizza, &c.]

## Monday, March 26, 2007

### angle between subspaces

Someone asked me this question today, which turns out to have a very elegant solution if you know a "decent amount" of linear algebra (say, at least one advanced class about matrix computations):

Given two subspaces of Rn, what is the angle between them?

To be rigorous, we could state this as: how can you efficiently find the minimum angle between any two nonzero vectors, one in subspace A, and the other in subspace B? I choose the minimum here because I feel that it corresponds most closely with our intuition in 3D in the case of a plane vs. a line. Given a line that intersects a plane at a single point (maybe picture a sundial in your mind), we usually think of "the angle" between the two as the smallest angle. It also seems more distance-like than the maximum angle since, for example, we expect the "distance" between a subspace and itself to be zero, which is true for the min angle, but not necessarily the max.

I'll post what I think is a nice solution in a little bit. In the meantime, can anyone think of how to answer this?

Anonymous said...

take orthonormal bases of each, stick the vectors into a matrix (square if the codims add to n = dim of ambient space), use sin inverse \circ det? (modulo minor adjustments if the codimensions don't add right) i don't know.

8:49 PM
Emilio said...

Intuition is a tricky friend here: if you consider any two planes in R3, the minimum angle between nonzero vectors, one in each plane, is zero. The angle we usually think of is the maximum of such angles. so which is it?

12:27 PM
Tyler said...

Wow, I just realized I never answered this (at least as far as I can find... weird).

I'll dig up my answer and post it here.

Btw, Emilio, good question. I think you can argue either way, but I would personally prefer the maximum angle for a few reasons - one of the main being that it acts more like a metric, in that it follows the rule angle(X,Y)=0 iff X=Y.

5:13 AM
Anonymous said...

Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!

9:40 AM
Emilio said...

The maximum angle won't work as a metric: it's false that max{angle(x,y): x in X, y in Y} = 0 iff X=Y, since if X has dimension more than one, (i.e. it contains a plane) then the maximum angle of X with itself is pi/2.

I believe that the usual procedure is to use a set of angles, equal to the arcsines or arccosines of the singular values of a matrix containing bases of both subspaces - or something like that. The name, I think, is Jordan's principal angles.

1:08 PM