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

  • 1
    $\begingroup$ When you say "completely new", does that mean too new to know about bases and basis changes? $\endgroup$ Oct 13, 2013 at 21:20
  • $\begingroup$ @DanielFischer Yup $\endgroup$
    – dsd
    Oct 13, 2013 at 21:23

6 Answers 6


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}$$

  • 1
    $\begingroup$ But what is an example of a far more elegant derivation? $\endgroup$ Apr 11, 2021 at 17:29

Another way. To reflect along a line that forms an angle $\theta$ with the horizontal axis is equivalent to:

  • rotate an angle $-\theta$ (to make the line horizontal)
  • invert the $y$ coordinate
  • 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}$$

  • 2
    $\begingroup$ Regarding the order: I'm using the same conventions as in the linked wikipedia page (points as column vectors, the standard x-y plane, positive rotations are counter-clockwise). Hence any composed transformation is written as $ p' = T p = T_2 T_1 p$ , i.e., the rightmost matrix in the multiplication corresponds to the firstly applied transformation. Further, my rightmost matrix corresponds to a rotation of $-\theta$ degrees (not 45 degrees!), i.e. $\theta$ degrees clockwise. $\endgroup$
    – leonbloy
    Jan 17, 2020 at 10:32
  • $\begingroup$ thanks for clarifying $\endgroup$
    – user454960
    Jan 17, 2020 at 10:35

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}$$


$$\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$.


It is derived from physics of reflection.

The reflected ray rotates by an amount equal to $2 \theta,$ if the mirror itself rotates by $\theta,$ when we are given

$$ \tan \theta = m$$

Rotation matrix for double angle

$$ \begin{pmatrix}\cos 2 \theta & \sin 2 \theta\\\sin 2 \theta &\cos 2 \theta\end{pmatrix}$$

Using Weierstrass half angle relations

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

for consistency of rotation direction. Cannot explain the sign.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.