Using the standard basis of $\mathbb{R}^2$, determine the matrix of the following linear transformation Using the standard basis of $\mathbb{R}^2$, determine the matrix of the following linear transformation
A reflection in a line forming an angle $\frac{\theta}{2}$ with the $x$-axis.
According to the solutions given in the book the result should be 
$\begin{pmatrix}
  \cos\theta & \sin\theta \\
  \sin\theta & -\cos\theta \\
\end{pmatrix}$.
I understand how to generally solve these types of problems, but the trigonometry is causing me difficulty. I would appreciate it if someone could include a graph and explain their workings in simple mathematical language.
Thank you.
 A: If you decompose a given vector $\mathbf v$ into a component $\mathbf v_\parallel$ that’s parallel to the given line and a component $\mathbf v_\perp$ that is perpendicular to it, it should be reasonably clear from the following diagram that the reflection $\mathbf v'$ of $\mathbf v$ in this line can be found by reversing $\mathbf v_\perp$.

Symbolically, $\mathbf v'=\mathbf v_\parallel-\mathbf v_\perp$, but $\mathbf v_\perp = \mathbf v-\mathbf v_\parallel$, therefore $\mathbf v'=2\mathbf v_\parallel-\mathbf v$. So, the problem is reduced to finding $\mathbf v_\parallel$.  
Let $\mathbf u=\langle\cos{\theta/2},\sin{\theta/2}\rangle^T$, i.e., a unit vector in the direction of the given line. Then $\mathbf v_\parallel$ is just the projection of $\mathbf v$ onto this vector, which is $$\begin{align}\mathbf v_\parallel &= (\mathbf u\cdot\mathbf v)\,\mathbf u \\ &= \left(v_x\cos{\theta\over2}+v_y\sin{\theta\over2}\right)\,\left\langle\cos{\theta\over2},\sin{\theta\over2}\right\rangle^T \\ &= \left\langle v_x\cos^2{\theta\over2}+v_y\cos{\theta\over2}\sin{\theta\over2}, v_x\cos{\theta\over2}\sin{\theta\over2}+v_y\sin^2{\theta\over2} \right\rangle^T,\end{align}$$ so $$\mathbf v' = \left\langle 2v_x\cos^2{\theta\over2}-v_x+2v_y\cos{\theta\over2}\sin{\theta\over2}, 2v_x\cos{\theta\over2}\sin{\theta\over2}+2v_y\sin^2{\theta\over2}-v_y \right\rangle^T.$$ In matrix form this is $$\begin{align}\mathbf v' &= \begin{bmatrix}2\cos^2{\theta\over 2}-1 & 2\cos{\theta\over2}\sin{\theta\over2} \\ 2\cos{\theta\over2}\sin{\theta\over2} & 2\sin^2{\theta\over2}-1\end{bmatrix}\mathbf v \\
&= \begin{bmatrix}\cos^2{\theta\over 2}-\sin^2{\theta\over 2} & 2\cos{\theta\over2}\sin{\theta\over2} \\ 2\cos{\theta\over2}\sin{\theta\over2} & \sin^2{\theta\over2}-\cos^2{\theta\over 2}\end{bmatrix}\mathbf v \\
&= \begin{bmatrix}\cos\theta & \sin\theta \\ \sin\theta & -\cos\theta\end{bmatrix}\mathbf v.\end{align}$$ The last step uses the double-angle formulas for sine and cosine.
A: To find the matrix of the reflection $f$, it suffices to find $f(e_1)$ and $f(e_2)$, where $e_1=(1,0)$ and $e_2=(0,1)$. Both vectors have unit lengths and the same will be true for their images.
It might help if you draw a picture.
The vector $e_1$ is at angle $0$ and the image $f(e_1)$ will have angle $\theta$, so it is the vector
$$f(e_1)=(\cos\theta,\sin\theta).$$
To find $f(e_2)$ the computation is slightly more complicated. Notice that $e_2$ has angle $\pi/2$ with the $x$-axis. And we have the axis of reflection, which is the line with the angle $\theta/2$. So the angle between $e_2$ and the axis of reflection is $\alpha=\pi/2-\theta/2$. And the angle of $f(e_2)$ will be $\pi/2-2\alpha$. (Notice that if we rotate $e_2$ by the angle $-\alpha$, we get a vector which is in the direction of the reflection axis.
If we do it once again, it is the result of reflection.) So we need to calculate $\pi/2-2\alpha$.
Now it is some simple algebraic manipulation
$$\frac\pi2-2\alpha = \frac\pi2-2\left(\frac\pi2-\frac\theta2\right) = \theta-\frac\pi2.$$
(As a kind of sanity check you might notice that $\frac{\frac\pi2+\left(\theta-\frac\pi2\right)}2=\frac\theta2$, so the reflection axis is exactly in the middle between $e_2$ and $f(e_2)$, just as expected.)
We know that the angle is $\theta-\pi/2$ and the vector has unit length, which means
$$f(e_2)=\left(\cos\left(\theta-\frac\pi2\right),\sin\left(\theta-\frac\pi2\right)\right).$$
This can be further simplified. We have
$\cos\left(\theta-\frac\pi2\right)=\cos\left(\frac\pi2-\theta\right)=\sin\theta$ and
$\sin\left(\theta-\frac\pi2\right)=-\sin\left(\frac\pi2-\theta\right)= -\cos\theta$.
So we got
$$f(e_2)=(\sin\theta,-\cos\theta).$$
And the matrix of the linear transformation is
$$\begin{pmatrix}
  \cos\theta & \sin\theta \\
  \sin\theta & -\cos\theta \\
\end{pmatrix}.$$
The determinant is
$$\begin{vmatrix}
  \cos\theta & \sin\theta \\
  \sin\theta & -\cos\theta \\
\end{vmatrix}=-\cos^2\theta-\sin^2\theta=-1.$$
(Exactly as expected, since this linear transformation preserves lengths but changes orientation.)
A: Try thinking of this transformation as a composition of three transformations.  First, map the line across which we want to reflect to the $x$-axis.  Then reflect across the $x$-axis, and finally rotate the $x$-axis back to the original line.  The first rotation is given by the matrix
\begin{equation}
\left(\begin{matrix} \cos(-\theta/2) & -\sin(-\theta/2)\\ \sin(-\theta/2) & \cos(-\theta/2)\end{matrix}\right).
\end{equation}
(Are you familiar with rotation matrices?)  Then the reflection across the $x$-axis is given by
\begin{equation}
\left(\begin{matrix} 1 & 0\\ 0 & -1\end{matrix}\right).
\end{equation}
Finally, we rotate back to our original line with
\begin{equation}
\left(\begin{matrix} \cos(\theta/2) & -\sin(\theta/2)\\ \sin(\theta/2) & \cos(\theta/2)\end{matrix}\right).
\end{equation}
We can obtain the desired matrix by multiplying these matrices together (pay attention to the order!).
