Decomposing a $2\times 2$ matrix into rotation and scaling How do you comprehensively decompose a 2x2 matrix into a scaling and a rotation matrix?
I understand that a rotation matrix looks like:
$$
    \begin{pmatrix}
    \cos \theta & -\sin\theta \\
    \sin\theta  & \cos \theta\\    
    \end{pmatrix}
$$
and a scaling matrix looks like:
$$
    \begin{pmatrix}
    \alpha & 0 \\
    0  & \alpha\\    
    \end{pmatrix}
$$
The matrix I want to decompose is  $$
    \begin{pmatrix}
    2 & -2 \\
    2  & 2\\    
    \end{pmatrix}
$$
The way they do it in my book is by defining the first column of a as vector $ r =(2,2)$. Then $|r| = 2 \sqrt{2} $. So the scaling factor $\alpha = 2\sqrt{2}$ and the rotation is $ \pi / 4 $
Can this be done with every matrix? And how about the second column. Doesn't that matter at all?
Many thanks in advance!
 A: A rotation perserves the angles, hence the columns of the matrix must be orthogonal. It also preserves the (ratios of) lengths and the columns must have the same Euclidean norm.
$$\begin{pmatrix}a&b\\c&d\end{pmatrix}$$ must be such that
$$ab+cd=0$$ and $$a^2+c^2=b^2+d^2.$$
In fact, these constraints imply that the matrix must be of the form
$$\begin{pmatrix}a&-c\\c&a\end{pmatrix}.$$
A: I think your book's explanation is a bit unintuitive. Really the key is to spot that this matrix
\begin{equation*}
 \begin{pmatrix} 2 & -2 \\ 2 & 2 \end{pmatrix}
\end{equation*}
looks a lot like a rotation already! Particularly, the diagonal elements are the same, and the off-diagonal elements differ by multiplication by $-1$. This is the form of a general scaling-rotation combination. In fact, if we multiply the general rotation and scaling matrices together, we get
\begin{equation*}
\begin{pmatrix} \alpha \sin \theta & -\alpha \cos \theta \\
 \alpha \cos \theta & \alpha \sin \theta \end{pmatrix}
\end{equation*}
which I'll leave as an exercise for you. Note that it doesn't matter if you multiply by the rotation on the left or the right, or in fact if you multiply by more rotations or scalings, the general form doesn't change! If you think about it geometrically, this makes sense. Rotating multiple times is the same as rotating once by the total angle of rotation, and scaling multiple times is the same as scaling once by the compound scale factor. Moreover, it doesn't matter if you scale first and then rotate, or rotate and then scale.
Anyway, we now want to find $\alpha$ and $\theta$ such that $\alpha \sin \theta = 2$, and $\alpha \cos \theta = 2$. (It should be clear that if we accomplish this, then the general matrix becomes the matrix we're looking for).
Now, looking at this, we can eliminate the trig functions by taking the sum of squares:
\begin{equation*}
 (\alpha \sin \theta)^2 + (\alpha \cos \theta)^2 = \alpha^2 = 2^2 + 2^2
\end{equation*}
ie $\alpha^2 = 8$. So let's take $\alpha = \sqrt 8 = 2 \sqrt 2$.
Then, substituting back in, it just remains to find $\theta$ such that
$\sin \theta = \cos \theta = \tfrac 12 \sqrt 2$. The special angle $\pi/4$ is fairly well-known to have this property. If you didn't know that, you could combine them to get $\tan \theta = 1$ and solve that, but you have to watch out that the solution to this is actually consistent with the two previous equations.
A way to think about why it works to square and add the equations is that the point $(\alpha \sin \theta, \alpha \cos \theta)$ lies on the circle centred at the origin with radius $\alpha$, so finding the distance from the origin tells us $\alpha$. This has a lot to do with your book's approach. Note that we could also have taken $\alpha = -2\sqrt 2$. Can you find what the corresponding $\theta$ would be?
Not all matrices can be written as such a product. Particularly, note that if two vectors are perpendicular to each other, then scaling and rotating them keeps them perpendicular. But for example, the matrix
\begin{equation*}
 \begin{pmatrix}
  1 & 0 \\
  0 & 0
 \end{pmatrix}
\end{equation*}
sends both of the perpendicular vectors $(1, 1)$ and $(1, -1)$ to $(1, 0)$. Another way to look at it is that not every matrix has the same general form I mentioned earlier.
