## Subsection2.2.5Examples of unitary matrices

In this unit, we will discuss a few situations where you may have encountered unitary matrices without realizing. Since few of us walk around pointing out to each other "Look, another matrix!" we first consider if a transformation (function) might be a linear transformation. This allows us to then ask the question "What kind of transformations we see around us preserve length?" After that, we discuss how those transformations are represented as matrices. That leaves us to then check whether the resulting matrix is unitary.

### Subsubsection2.2.5.1Rotations

A rotation in 2D, $R_{\theta}: \R^2 \rightarrow \R^2 \text{,}$ takes a vector and rotates that vector through the angle $\theta \text{:}$

• If you scale a vector first and then rotate it, you get the same result as if you rotate it first and then scale it.

• If you add two vectors first and then rotate, you get the same result as if you rotate them first and then add them.

Thus, a rotation is a linear transformation. Also, the above picture captures that a rotation preserves the length of the vector to which it is applied. We conclude that the matrix that represents a rotation should be a unitary matrix.

Let us compute the matrix that represents the rotation through an angle $\theta \text{.}$ Recall that if $L : \Cn \rightarrow \Cm$ is a linear transformation and $A$ is the matrix that represents it, then the $j$th column of $A \text{,}$ $a_j \text{,}$ equals $L( e_j \text{.}$ The pictures

and

illustrate that

\begin{equation*} R_\theta( e_0 ) = \left( \begin{array}{c} \cos( \theta ) \\ \sin( \theta ) \end{array} \right) \quad \mbox{and} \quad R_\theta( e_1 ) = \left( \begin{array}{c} - \sin( \theta ) \\ \cos( \theta ) \end{array} \right) . \end{equation*}

Thus,

\begin{equation*} R_\theta( x ) = \left( \begin{array}{c | c} \cos(\theta) \amp - \sin( \theta ) \\ \sin( \theta) \amp \cos( \theta ) \end{array} \right) \left( \begin{array}{c} \chi_0 \\ \hline \chi_1 \end{array} \right). \end{equation*}
###### Homework2.2.5.1.

Show that

\begin{equation*} \left( \begin{array}{r r} \cos(\theta) \amp - \sin( \theta ) \\ \sin( \theta) \amp \cos( \theta ) \end{array} \right) \end{equation*}

is a unitary matrix. (Since it is real valued, it is usually called an orthogonal matrix instead.)

Hint

Hint: use $c$ for $\cos( \theta )$ and $s$ for $\sin( \theta )$ to save yourself a lot of writing!

Solution
\begin{equation*} \begin{array}{l} \left( \begin{array}{r | r} \cos(\theta) \amp - \sin( \theta ) \\ \sin( \theta) \amp \cos( \theta ) \end{array} \right)^H \left( \begin{array}{r | r} \cos(\theta) \amp - \sin( \theta ) \\ \sin( \theta) \amp \cos( \theta ) \end{array} \right) \\ ~~~=~~~~ \lt \mbox{ the matrix is real valued } \gt \\ \left( \begin{array}{r | r} \cos(\theta) \amp - \sin( \theta ) \\ \sin( \theta) \amp \cos( \theta ) \end{array} \right)^T \left( \begin{array}{r | r} \cos(\theta) \amp - \sin( \theta ) \\ \sin( \theta) \amp \cos( \theta ) \end{array} \right) \\ ~~~=~~~~ \lt \mbox{ transpose } \gt \\ \left( \begin{array}{r r} \cos(\theta) \amp \sin( \theta ) \\ \hline - \sin( \theta) \amp \cos( \theta ) \end{array} \right) \left( \begin{array}{r | r} \cos(\theta) \amp - \sin( \theta ) \\ \sin( \theta) \amp \cos( \theta ) \end{array} \right) \\ ~~~=~~~~ \lt \mbox{ multiply } \gt \\ \left( \begin{array}{c | c} \cos^2(\theta) + \sin^2(\theta) \amp - \cos( \theta) \sin( \theta ) + \sin( \theta ) \cos( \theta ) \\ \hline - \sin( \theta) \cos( \theta ) + \cos( \theta ) \sin( \theta ) \amp \sin^2(\theta) + \cos^2( \theta ) \end{array} \right) \\ ~~~=~~~~ \lt \mbox{ geometry; algebra } \gt \\ \left( \begin{array}{c c} 1 \amp 0 \\ 0 \amp 1 \end{array} \right) \\ \end{array} \end{equation*}
###### Homework2.2.5.2.

Prove, without relying on geometry but using what you just discovered, that $\cos( - \theta ) = \cos( \theta )$ and $\sin( - \theta ) = - \sin( \theta )$

Solution

Undoing a rotation by an angle $\theta$ means rotating in the opposite direction through angle $\theta$ or, equivalently, rotating through angle $- \theta \text{.}$ Thus, the inverse of $R_{\theta}$ is $R_{-\theta} \text{.}$ The matrix that represents $R_{\theta}$ is given by

\begin{equation*} \left( \begin{array}{c c} \cos( \theta ) \amp - \sin( \theta ) \\ \sin( \theta ) \amp \cos( \theta ) \end{array} \right) \end{equation*}

and hence the matrix that represents $R_{-\theta}$ is given by

\begin{equation*} \left( \begin{array}{c c} \cos( -\theta ) \amp - \sin( -\theta ) \\ \sin( -\theta ) \amp \cos( -\theta ) \end{array} \right) . \end{equation*}

Since $R_{-\theta}$ is the inverse of $R_{\theta}$ we conclude that

\begin{equation*} \left( \begin{array}{c c} \cos( \theta ) \amp - \sin( \theta ) \\ \sin( \theta ) \amp \cos( \theta ) \end{array} \right)^{-1} = \left( \begin{array}{c c} \cos( -\theta ) \amp - \sin( -\theta ) \\ \sin( -\theta ) \amp \cos( -\theta ) \end{array} \right) . \end{equation*}

But we just discovered that

\begin{equation*} \left( \begin{array}{c c} \cos( \theta ) \amp - \sin( \theta ) \\ \sin( \theta ) \amp \cos( \theta ) \end{array} \right)^{-1} = \left( \begin{array}{c c} \cos( \theta ) \amp - \sin( \theta ) \\ \sin( \theta ) \amp \cos( \theta ) \end{array} \right)^T = \left( \begin{array}{c c} \cos( \theta ) \amp \sin( \theta ) \\ - \sin( \theta ) \amp \cos( \theta ) \end{array} \right) . \end{equation*}

Hence

\begin{equation*} \left( \begin{array}{c c} \cos( -\theta ) \amp - \sin( -\theta ) \\ \sin( -\theta ) \amp \cos( -\theta ) \end{array} \right) . = \left( \begin{array}{c c} \cos( \theta ) \amp \sin( \theta ) \\ - \sin( \theta ) \amp \cos( \theta ) \end{array} \right) \end{equation*}

from which we conclude that $\cos( - \theta ) = \cos( \theta )$ and $\sin( - \theta ) = -\sin( \theta ) \text{.}$

### Subsubsection2.2.5.2Reflections

Picture a mirror with its orientation defined by a unit length vector, $u \text{,}$ that is orthogonal to it.

We will consider how a vector, $x \text{,}$ is reflected by this mirror.

The component of $x$ orthogonal to the mirror equals the component of $x$ in the direction of $u \text{,}$ which equals $(u^T x) u \text{.}$

The orthogonal projection of $x$ onto the mirror is then given by the dashed vector, which equals $x - (u^Tx) u \text{.}$

To get to the reflection of $x \text{,}$ we now need to go further yet by $-(u^Tx) u \text{.}$

We conclude that the transformation that mirrors (reflects) $x$ with respect to the mirror is given by $M( x ) = x - 2( u^T x ) u \text{.}$

The transformation described above preserves the length of the vector to which it is applied.

###### Homework2.2.5.3.

(Verbally) describe why reflecting a vector as described above is a linear transformation.

Solution
• If you scale a vector first and then reflect it, you get the same result as if you reflect it first and then scale it.

• If you add two vectors first and then reflect, you get the same result as if you reflect them first and then add them.

###### Homework2.2.5.4.

Show that the matrix that represents $M: \R^3 \rightarrow \R^3$ in the above example is given by $I - 2 u u^T \text{.}$

Hint

Rearrange $x - 2 ( u^T x ) u \text{.}$

Solution

We notice that

\begin{equation*} \begin{array}{l} x - 2 ( u^T x ) u \\ ~~~ = ~~~~ \lt \alpha x = x \alpha \gt \\ x - 2u ( u^T x ) \\ ~~~ = ~~~~ \lt \mbox{ associativity } \gt \\ I x - 2u u^T x \\ ~~~ = ~~~~ \lt \mbox{ distributivity } \gt \\ ( I - 2 u u^T ) x. \end{array} \end{equation*}

Hence $M( x ) = ( I -2 u u^T ) x$ and the matrix that represents $M$ is given by $I - 2 u u^T \text{.}$

###### Homework2.2.5.5.

(Verbally) describe why $( I - 2 u u^T )^{-1} = I - 2 u u^T$ if $u \in \R^3$ and $\| u \|_2 = 1 \text{.}$

Solution

If you take a vector, $x \text{,}$ and reflect it with respect to the mirror defined by $u \text{,}$ and you then reflect the result with respect to the same mirror, you should get the original vector $x$ back. Hence, the matrix that represents the reflection should be its own inverse.

###### Homework2.2.5.6.

Let $M: \R^3 \rightarrow \R^3$ be defined by $M(x ) = (I - 2 u u^T) x \text{,}$ where $\| u \|_2 = 1 \text{.}$ Show that the matrix that represents it is unitary (or, rather, orthogonal since it is in $\R^{3 \times 3}$).

Solution

Pushing through the math we find that

\begin{equation*} \begin{array}{l} (I - 2 u u^T)^T ( I - 2 u u^T ) \\ ~~~=~~~~ \lt ( A + B )^T = A^T + B^T \gt \\ ( I^T - ( 2 u u^T )^T ) ( I - 2 u u^T ) \\ ~~~=~~~~ \lt ( \alpha A B^T )^T = \alpha B A^T \gt \\ ( I - 2 u u^T ) ( I - 2 u u^T ) \\ ~~~=~~~~ \lt \mbox{ distributivity } \gt \\ ( I - 2 u u^T ) - ( I - 2 u u^T ) ( 2 u u^T ) \\ ~~~=~~~~ \lt \mbox{ distributivity } \gt \\ I - 2 u u^T - 2 u u^T + 2 u u^T 2 u u^T \\ ~~~=~~~~ \lt u^T u = 1 \gt \\ I - 4 u u^T + 4 u u^T \\ ~~~ = ~~~~ \lt A - A = 0 \gt \\ I. \end{array} \end{equation*}
###### Remark2.2.5.1.

Unitary matrices in general, and rotations and reflections in particular, will play a key role in many of the practical algorithms we will develop in this course.