# Chaitanya's Random Pages

## November 16, 2012

### When is a matrix the inverse of itself?

Filed under: mathematics — ckrao @ 11:51 am

Recently I was playing around with matrices and noticed that matrices such as $\displaystyle \left[ \begin{array}{cc} 1 & 0 \\ -1 & -1 \end{array} \right]$ and $\displaystyle \left[ \begin{array}{cc} 1 & 0 \\ 1 & -1 \end{array} \right]$ are equal to their inverse. In other words, they are matrices $A$ such that $A^{-1} = A$ or $A^2 = I$ where $I$ is the 2 by 2 identity matrix. This led me to wonder which 2×2 matrices in general had this property. I may have worked this out previously but I could not recall the condition. In this post we’ll see the general form of such matrices and then generalise the result to higher dimensions.

For 2×2 matrices the inverse of the matrix $\displaystyle \left[ \begin{array}{cc} a & b \\ c & d \end{array} \right]$ is $\displaystyle \frac{1}{ad-bc} \left[ \begin{array}{cc} d & -b \\ -c & a \end{array} \right]$, where $ad -bc \neq 0$.

Hence matching one of the entries of these two matrices, $b = \frac{-b}{ad-bc}$. From this, either $b= 0$ or $ad -bc = -1$.

1) If $b = 0$, the inverse becomes

$\displaystyle \left[ \begin{array}{cc} 1/a & 0 \\ -c/ad & 1/d \end{array} \right] ,$

from which $a = 1/a, d = 1/d$ and $c = -c/ad$ (and hence $c = 0$ or $ad = -1$). This leads to the forms $\displaystyle \left[ \begin{array}{cc} \pm 1 & 0 \\ 0 & \pm 1 \end{array} \right] , \left[ \begin{array}{cc} \pm 1 & 0 \\ c & \mp 1 \end{array} \right]$.

2) If $ad -bc = -1$, the inverse becomes

$\displaystyle \left[ \begin{array}{cc} -d & b \\ c & -a \end{array} \right] ,$

from which $a = -d$. This leads to the form $\displaystyle \left[ \begin{array}{cc} a & b \\c & -a \end{array} \right]$ where $a^2 + bc = 1$.

Combining the two cases (and noting that there is overlap between the two) , we conclude that the 2×2 matrices that are inverses of themselves are either

• $\displaystyle I = \left[ \begin{array}{cc} 1 & 0 \\ 0 & 1 \end{array} \right]$
• $\displaystyle -I = \left[ \begin{array}{cc} -1 & 0 \\ 0 & -1 \end{array} \right]$
•   $\displaystyle \left[ \begin{array}{cc} a & b \\c & -a \end{array} \right]$ where $a^2 + bc = 1$.

To check for this final case we simply need to ensure that (1) the matrix has determinant -1 and (2) the matrix has diagonal entries summing to 0. For example, the matrix $\displaystyle A = \left[ \begin{array}{cc} 3 & 2 \\-4 & -3 \end{array} \right]$ has this property so we can immediately say $A^2 = I$, or indeed $A^{17} = A$ if we desire. 🙂

An alternative approach, that works more generally for nxn matrices, uses some knowledge of linear algebra. Our desired matrices satisfy the equation $A^2 = I$ or $A^2 - I = 0$. Hence the minimal polynomial of $A$ is a factor of $x^2 -1 = (x-1)(x+1)$. If it is either $(x-1)$ or $(x+1)$ this corresponds to the solutions $A = \pm I$. If the minimal polynomial is $(x-1)(x+1)$, the fact that there are no repeated factors (i.e. each root has multiplicity 1) implies that $A$ is diagonalisable. In this case, $A$ is similar to a diagonal matrix with +1 or -1 as the diagonal entries.

Hence $A = \pm I_n$ or $A = Q DQ^{-1}$ where $D = \displaystyle \left[ \begin{array}{cc} I_r & 0_{r\times s} \\ 0_{s \times r} & -I_s \end{array} \right]$, $r + s = n$ and $I_k$ represents the $k \times k$ identity matrix (and $0_{m \times n}$ is an $m \times n$ submatrix of 0s). In the special case of $n = 2$ this means we can also write $A = Q DQ^{-1}$ with $\displaystyle Q = \left[ \begin{array}{cc} a & b \\ c & d \end{array} \right]$ and $\displaystyle D = \left[ \begin{array}{cc} 1 & 0 \\ 0 & -1 \end{array} \right]$ and obtain

$\displaystyle A = \frac{1}{ad - bc} \left[ \begin{array}{cc} ad + bc & -2ab \\ 2cd & -ad -bc \end{array} \right].$

Note here that the diagonal entries sum to 0 and $\displaystyle \det A = \frac{-(ad + bc)^2 + 4abcd}{(ad - bc)^2} = -1$.

Matrices that satisfy $A = A^{-1}$ or $A^2 = I$ are known as involutory. Such matrices have applications in cryptography where it may be useful for the same matrix operation to act as its inverse in decryption. We have the following two further characterisations of involutory matrices (holding true in any field of characteristic not equal to 2).

1. $A = 2P - I$, where $P$ satisfies $P^2 = P$ ($P$ is then known as an idempotent matrix).
To see this, simply note that if $A^2 = I$, the matrix $P:= (I+A)/2$ is idempotent since $P^2 = (I + A)^2/4 = (A^2 + 2A + I)/4 = (2I + 2A)/4 = P$. Conversely, if $A = 2P - I$, then $A^2 = (2P-I)^2 = 4P^2 - 4P + I = 4P - 4P + I = I$.
2. (See [1]) $A = \pm I$ or $A = I_n - Q_2 P_2$ where $Q_2$ is $n \times s$, $P_2$ is $s \times n$ and $P_2 Q_2 = 2I_s$.

To see this, we write $A = Q^{-1}DQ$ as before and partition $Q$ and $Q^{-1}$ as $\displaystyle Q = \left[ \begin{array}{cc} Q_1' & Q_2' \end{array} \right]$, $\displaystyle Q^{-1} = \left[ \begin{array}{c} P_1 \\ P_2 \end{array} \right]$ where $Q_2$ is $n \times s$ and $P_2$ is $s \times n$. Then $QQ^{-1} = I_n = Q_1 P_1 + Q_2 P_2$ while $\displaystyle Q^{-1} Q = \left[ \begin{array}{cc} P_1 Q_1' & P_1 Q_2' \\ P_2 Q_1' & P_2 Q_2' \end{array} \right] = \left[ \begin{array}{cc} I_r & o \\ 0 & I_s \end{array} \right] .$

Then

\begin{aligned} A &= Q D Q^{-1} \\ &= \left[ \begin{array}{cc} Q_1' & Q_2' \end{array} \right] \left[ \begin{array}{cc} I_r & 0_{r\times s} \\ 0_{s \times r} & -I_s \end{array} \right] \left[ \begin{array}{c} P_1 \\ P_2 \end{array} \right] \\ &= Q_1' P_1 - Q_2'P_2\\ &= I_n - Q_2'P_2 - Q_2'P_2\\ &= I_n - Q_2 P_2, \end{aligned}

where $Q_2 = 2Q_2'$ and $P_2 Q_2 = 2P_2 Q_2' = 2 I_s$.

The converse (that if $A$ has this form then it is involutory) is easier to prove: if $P_2 Q_2 = 2I_s$ then

$\displaystyle (I - Q_2 P_2)^2 = I^2 + Q_2 P_2 Q_2 P_2 - 2 Q_2 P_2 = I + 2 Q_2 P_2 - 2 P_2 P_2 = I.$

As an example, since $\displaystyle \left[ \begin{array}{ccc} 1 & 3 & 2 \end{array} \right] \left[ \begin{array}{c} 1 \\ 3 \\ -4\end{array} \right] = 1 + 9 - 8 = 2 = 2I_1$, the matrix

$\displaystyle P = \left[ \begin{array}{ccc} 1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1 \end{array} \right] - \left[ \begin{array}{c} 1 \\ 3 \\ -4 \end{array} \right] \left[ \begin{array}{ccc} 1 & 3 & 2 \end{array} \right] = \left[ \begin{array}{ccc} 0 & -3 & -2 \\ -3 & -8 & -6 \\ 4 & 12 & 9 \end{array} \right]$

has the property that $P^2 = I_3$ or $P^{-1} = P$.

#### Reference

[1] J. Levine and H. M. Nahikian, On the Construction of Involutory Matrices, The American Mathematical Monthly, Vol. 69, No. 4 (Apr 1962), pp. 267-272.

1. […] are some classes of real non-singular matrices that are easier to invert than most. In an earlier post I had referred to involutory matrices that had the special property that they were equal to their […]

Pingback by Matrices that are easy to invert « Chaitanya's Random Pages — December 12, 2012 @ 12:46 pm

2. Very interesting post. However, I was not able to replicate your example for P in MATLAB. I believe that
you made errors in calculating P. See below

P =

0 3 2
-3 8 6
4 12 9

>> P*P

ans =

-1 48 36
0 127 96
0 216 161

Pdave =

0 -3 -2
-3 -8 -6
4 12 9

>> Pdave*Pdave

ans =

1 0 0
0 1 0
0 0 1

Comment by Dave — October 10, 2015 @ 2:44 pm

• Yes you are quite right, this has now been corrected. Thanks!

Comment by ckrao — November 3, 2015 @ 2:18 am

Create a free website or blog at WordPress.com.