# Reflection across a line?

The linear transformation matrix for a reflection across the line $y = mx$ is:

$$\frac{1}{1 + m^2}\begin{pmatrix}1-m^2&2m\\2m&m^2-1\end{pmatrix}$$

My professor gave us the formula above with no explanation why it works. I am completely new to linear algebra so I have absolutely no idea how to go about deriving the formula. Could someone explain to me how the formula is derived? Thanks

• When you say "completely new", does that mean too new to know about bases and basis changes? – Daniel Fischer Oct 13 '13 at 21:20
• @DanielFischer Yup – dsd Oct 13 '13 at 21:23

You can have (far) more elegant derivations of the matrix when you have some theory available. The low-tech way using barely more than matrix multiplication would be:

The line $y = mx$ is parametrised by $t \cdot \begin{pmatrix}1\\m\end{pmatrix}$. The line orthogonal to it is parametrised by $r \cdot \begin{pmatrix}-m\\1\end{pmatrix}$. The line $y = mx$ shall be fixed, the line orthogonal to it shall be reflected, so you want a matrix $R$ with

$$R \begin{pmatrix}1 & -m\\ m & 1\end{pmatrix} = \begin{pmatrix}1 & m\\ m & -1\end{pmatrix},$$

and that means

\begin{align} R &= \begin{pmatrix}1 & m\\m&-1\end{pmatrix} \begin{pmatrix}1&-m\\m&1\end{pmatrix}^{-1}\\ & = \begin{pmatrix}1&m\\m&-1\end{pmatrix}\cdot \frac{1}{1+m^2}\begin{pmatrix}1&m\\-m&1\end{pmatrix}\\ &= \frac{1}{1+m^2} \begin{pmatrix}1 - m^2 & 2m\\2m &m^2-1\end{pmatrix}. \end{align}

Another way: to reflect along a line that forms an angle $$\theta$$ with the horizontal is equivalent to rotate an angle $$-\theta$$ (to make the line horizontal), invert the $$y$$ coordinate, and then rotate $$\theta$$ back.

Further, $$y=mx$$ implies $$\tan \theta = m$$, and $$1+m^2 = \frac{1}{\cos^2\theta}$$ .

Then, assumming you know about rotation matrices, you can write

\begin{align}T&=\begin{pmatrix}\cos \theta & -\sin \theta\\ \sin \theta & \cos \theta\end{pmatrix} \begin{pmatrix}1&0\\ 0 & -1\end{pmatrix} \begin{pmatrix}\cos \theta & \sin \theta\\ -\sin \theta & \cos \theta\end{pmatrix} \\ &= \begin{pmatrix}\cos \theta & -\sin \theta\\ \sin \theta & \cos \theta\end{pmatrix} \begin{pmatrix}\cos \theta & \sin \theta\\ \sin \theta & -\cos \theta\end{pmatrix} \\ &= \cos^2 \theta \begin{pmatrix}1 & -\tan \theta\\ \tan \theta & 1\end{pmatrix} \begin{pmatrix}1 & \tan \theta\\ \tan\theta & -1\end{pmatrix} \\ &= \frac{1}{1 + m^2} \begin{pmatrix}1 & -m\\ m & 1\end{pmatrix} \begin{pmatrix}1 & m\\ m & -1\end{pmatrix} \\ &=\frac{1}{1 + m^2}\begin{pmatrix}1-m^2&2m\\2m&m^2-1\end{pmatrix}\end{align}

Vectors on the line obey the equation

$$y - mx = 0$$

Let $e_x, e_y$ be Cartesian basis vectors associated with the $x, y$ coordinates, respectively. The above equation implies that any vector $r = x e_x + y e_y$ that lies on the line must satisfy

$$r \cdot n = 0, \quad n = -m e_x + e_y$$

The vector $n$ is the normal vector to the line, perpendicular to the line. The associated unit normal is $\hat n = n/\sqrt{1+m^2}$.

Any vector $a$ can be broken down into a component that is parallel to the line and a component that is perpendicular. This is written $a = a_\parallel + a_\perp$. When the vector is reflected by a reflection map $\underline N$, the perpendicular component changes sign; the parallel component does not. That is,

$$\underline N(a) = a_\parallel - a_\perp = a - 2 a_\perp$$

The perpendicular component $a_\perp$ is given by

$$a_\perp = (a \cdot \hat n) \hat n$$

where $a = a^x e_x + a^y e_y$. You should be able to recognize that this is merely a projection map onto the vector $\hat n$.

Thus, the reflection map is given as

$$\underline N(a) = \underline I(a) - 2(a \cdot \hat n) \hat n$$

where $\underline I$ is the identity map.

From here, one need only evaluate this in terms of basis vectors to find the matrix components.

$$\underline N(e_x) = e_x - 2 (e_x \cdot \hat n) \hat n = e_x - \frac{2(-m)(-m e_x + e_y)}{1 + m^2} = \frac{(1-m^2)e_x + 2m e_y}{1+m^2}$$

and

$$\underline N(e_y) = e_y - 2 (e_y \cdot \hat n) \hat n = e_y - \frac{2(1)(-me_x + e_y)}{1+m^2} = \frac{2m e_x + (m^2 - 1)e_y}{1+m^2}$$

Both of these are columns of the associated matrix representation.

Here is a slightly different take. One can check with a picture that $R=2P-I$, where $P$ is the projection onto the line. Taking $v=(1,m)^T$ a vector along the line, then $$P\begin{bmatrix} x\\ y\end{bmatrix} = \begin{bmatrix} 1&m\end{bmatrix} \begin{bmatrix} x\\ y\end{bmatrix}\,\begin{bmatrix} 1\\ m\end{bmatrix} / \begin{bmatrix} 1&m\end{bmatrix} \begin{bmatrix} 1\\ m\end{bmatrix} =\frac1{1+m^2} \begin{bmatrix} x+my\\ mx+m^2y\end{bmatrix}.$$ So $$P=\frac1{1+m^2} \begin{bmatrix} 1&m\\ m&m^2\end{bmatrix}$$ and $$R=2P-I=\frac1{1+m^2} \begin{bmatrix} 1-m^2&2m\\ 2m&m^2-1\end{bmatrix}.$$

If you made a sketch you will se that $R(x)=2 \Pi_v(x)-x$ where $v=(1,m)$ and $\Pi_v$ is the projection of the vector $x$ over the vector $v$.