# Rotation Matrix inverse using Gauss-Jordan elimination

I'd like to calculate the inverse of a rotation matrix, let take the simplest case which is a $2$ x $2$ rotation matrix:

$R =\begin{bmatrix} \cos \theta & -\sin \theta \\[0.3em] \sin \theta & \cos \theta \end{bmatrix}$

I know that the inverse is the following

$R^{-1} =\begin{bmatrix} \cos \theta & \sin \theta \\[0.3em] -\sin \theta & \cos \theta \end{bmatrix}$

and I know that I can calculate it using the transpose method as such:

$R^{-1}=R^T$

but I fail to calculate the inverse using $Gauss-Jordan$ elimination, that is I don't know how to substract $\cos \theta$ from $\sin \theta$ in the second row. It all gets a bit complicated; I've looked around and nobody has a full step method using $G.-J.$ only the solution or the transpose method. Could someone provide me a full-step solution using $G.-J.$?

$$\begin{bmatrix} \cos t&-\sin t&|&1&0\\ \sin t&\cos t&|&0&1 \end{bmatrix} \xrightarrow{\frac1{\cos t}R1} \begin{bmatrix} 1 &-\frac{\sin t}{\cos t}&|&\frac1{\cos t}&0\\ \sin t&\cos t&|&0&1 \end{bmatrix} \xrightarrow{R2-\sin t\,R1} \begin{bmatrix} 1 &-\frac{\sin t}{\cos t}&|&\frac1{\cos t}&0\\ 0&\cos t+\frac{\sin^2t}{\cos t}&|&-\frac{\sin t}{\cos t}&1 \end{bmatrix}= \begin{bmatrix} 1 &-\frac{\sin t}{\cos t}&|&\frac1{\cos t}&0\\ 0&\frac1{\cos t}&|&-\frac{\sin t}{\cos t}&1 \end{bmatrix} \xrightarrow{\cos t\,R2} \begin{bmatrix} 1 &-\frac{\sin t}{\cos t}&|&\frac1{\cos t}&0\\ 0&1&|&-\sin t&\cos t \end{bmatrix} \xrightarrow{R1+\frac{\sin t}{\cos t}R2} \begin{bmatrix} 1 &0&|&\frac1{\cos t}-\frac{\sin^2t}{\cos t}&\sin t\\ 0&1&|&-\sin t&\cos t \end{bmatrix} =\begin{bmatrix} 1 &0&|&\cos t&\sin t\\ 0&1&|&-\sin t&\cos t \end{bmatrix}$$

This is a terrible method to calculate the inverse of any $2\times 2$ matrix.

Edit: of course this does not work when $\cos t=0$; but this is a much easier case: you simply divide by $\sin t$ and permute the rows.

• "Exercise for the interested reader: work out the case $\cos t =0$." :-) – Agustí Roig Oct 27 '13 at 1:27
• That's actually quite good! Thanks for giving a detailed and concise method, although I understand why it is terrible. I could not figure out how do that because I was thinking in a different way. – jtimz Oct 27 '13 at 1:30
• @Agustí: Good point :D – Martin Argerami Oct 27 '13 at 1:30

To simplify notation let $s = \sin (\theta)$, $c = \cos(\theta)$.

If $\theta \neq \pm\pi/2, \$ ($c = 0$ here), then

$R =$ \begin{align*} &\begin{bmatrix} c & -s \\ s & c \end{bmatrix} \sim \\ &\begin{bmatrix} c^2 & -sc \\ s^2 & sc \end{bmatrix} \sim \\ (c^2 + s^2 = 1, right?) &\begin{bmatrix} 1 & 0 \\ s^2 & sc \end{bmatrix} \sim \\ &\begin{bmatrix} 1 & 0 \\ s/c & 1 \end{bmatrix} \end{align*} then finish it off!

If $\theta = \pm \pi/2$, then $\theta \neq 0$ or $\pi$, so perform the similar set of operations first swapping the two rows and ending with a divide-by-$\sin$.

QED

Allow $\theta$ to remain symbolic until the operation is complete. I'm assuming if you had real numbers to plug in then taking the inverse would be trivial.

\begin{bmatrix} c &-s &| &1 &0\\ s & c &| &0 & 1\\ \end{bmatrix} Multiply top line by c \begin{bmatrix} c^2 &-sc &| &c &0\\ s & c &| &0 & 1\\ \end{bmatrix} Bottom line by s \begin{bmatrix} c^2 &-sc &| &c &0\\ s^2 & sc &| &0 & s\\ \end{bmatrix} Add bottom line to top \begin{bmatrix} c^2+s^2 &sc-sc &| &c &s\\ s^2 & sc &| &0 & s\\ \end{bmatrix} Reduce \begin{bmatrix} 1 & 0 &| &c &s\\ s^2 & sc &| &0 & s\\ \end{bmatrix} Multiply top line by $-s^2$ and add to bottom line \begin{bmatrix} 1 & 0 &| &c &s\\ s^2-s^2 & sc &| &-cs^2 & s-s^3\\ \end{bmatrix} Reduce \begin{bmatrix} 1 & 0 &| &c &s\\ 0 & sc &| &-cs^2 & s-s^3\\ \end{bmatrix} Divide bottom line by $s$ \begin{bmatrix} 1 & 0 &| &c &s\\ 0 & c &| &-cs & 1-s^2\\ \end{bmatrix} Note that Pythagorean Theorem gives $c^2 = 1-s^2$ \begin{bmatrix} 1 & 0 &| &c &s\\ 0 & c &| &-cs & c^2\\ \end{bmatrix} Divide bottom line by $c$ \begin{bmatrix} 1 & 0 &| &c &s\\ 0 & 1 &| &-s & c\\ \end{bmatrix} Again, if you want to make specific cases for theta $(=\pi/2,0,etc.)$, then just plug those specific values of $\theta$ in. Notice I did not carry any fractions through; every time I divided by a trig term if fully canceled terms in the numerators.