# Find inverse of a matrix filled with 1 and -1 on main diagonal

Find the inverse of the matrix:

$\begin{bmatrix} -1 & 1 & 1 & \dots & 1 \\ 1 & -1 & 1 & \dots & 1 \\ ... & ... & ... & ... & ...\\ 1 & 1 & 1 & \dots & -1 \end{bmatrix}$

I tried adding the first line to each of the following lines, then dividing lines $2, 3,... n$ with 2, then changing the second line with the last one but I couldn't continue the algorithm.

• Work out initial cases and induct. – Rene Schipperus Dec 1 '17 at 19:56
• The inverse is of similar form: the main diagonal has an elemnt $a,$ all other positions have an element $b.$ Depend on size $n,$ of course, demand $n \geq 3$ – Will Jagy Dec 1 '17 at 20:00

Assume the inverse has the same structure as the given matrix \begin{eqnarray*} \begin{bmatrix} -1 & 1 & 1 & \cdots & 1 \\ 1 & -1 & 1 & \cdots & 1 \\ 1 & 1 & -1 & \cdots & 1 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & 1 & 1 & \cdots & -1 \end{bmatrix} \begin{bmatrix} a & b & b & \cdots & b \\ b & a & b & \cdots & b \\ b & b & a & \cdots & b \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ b & b & b & \cdots & a \end{bmatrix}= \begin{bmatrix} 1 & 0 & 0 & \cdots & 0 \\ 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \cdots & 1 \end{bmatrix} \end{eqnarray*} Now solve \begin{eqnarray*} -a +(n-1)b=1 \\ a+(n-3)b=0 . \end{eqnarray*} This gives \begin{eqnarray*} b= \frac{1}{2(n-2)} \\ a=-\frac{n-3}{2(n-2)}. \end{eqnarray*}

• Ok, so what do you get. ? – Rene Schipperus Dec 1 '17 at 20:10
• Why can I assume it has the same structure ? – Liviu Dec 1 '17 at 20:28
• It is a guess that the inverse has the same structure, that turns out to be true & hence gives us a nice quick route to calculating the inverse. – Donald Splutterwit Dec 1 '17 at 20:33

This answer is intended to supplement Donald Splutterwit’s educated guess that the inverse has the same form as the original matrix.

You know that the inverse matrix is at least going to be symmetric since the original one is. You also know that (or can find out from other questions here) that the eigenvalues of a matrix that has $a$’s along the main diagonal and $b$’s elsewhere are $a+(n-1)b$, with multiplicity $1$, and $a-b$, with multiplicity $n-1$. Moreover, you can find by inspection that the first eigenspace is spanned by $[1,1,1,\dots,1]^T$, while a basis for the second eigenspace is $$\{[1,-1,0,0,\dots,0]^T,[1,0,-1,0,\dots,0]^T,\dots,[1,0,0,0,\dots,-1]^T\}.$$ Observe that this eigenbasis is valid for every matrix of this form, so that every such matrix can be generated by a suitable choice of eigenvalues. Working in the other direction, then, if we start with eigenvalues $\lambda$ and $\mu$, we can find the entries of the resulting matrix by solving the system $\lambda = a+(n-1)b$, $\mu = a-b$ for $a$ and $b$: $$a = b+\mu, b = {\lambda-\mu \over n}.$$ If the matrix is nonsingular, then the eigenvalues of its inverse are the reciprocals of its eigenvalues, with the same multiplicites and eigenspaces, and so the inverse matrix does indeed have the same form.

For your matrix, the eigenvalues are $n-2$ and $-2$, so the inverse eigenvalues are $\frac1{n-2}$ and $-\frac12$, and therefore the inverse matrix has $-{n-3\over2n-4}$ on the main diagonal and ${1\over2n-4}$ elsewhere. When $n=2$, the matrix is singular, as should be obvious by inspection.

For $2n+1$ and $2n$: $$\begin{pmatrix} -n&1&1&1&1\\ 1&-n&1&1&1\\ 1&1&-n&1&1\\ 1&1&1&-n&1\\ 1&1&1&1&-n\ \end{pmatrix}$$ times an appropriate constant.

If you denote by $E$ the matrix consisting of all ones, then you have $E^2=nE$ and $$A=E-2I.$$ From this you get $AE=(E-2I)E=E^2-2E=nE-2E=(n-2)E.$ Hence \begin{align*} AE&=(n-2)E\\ AE-(n-2)A&=2(n-2)I\\ A[E-(n-2)I]&=2(n-2)I\\ A\cdot\frac{E-(n-2)I}{2(n-2)}&=I \end{align*} and you get that $$A^{-1}=\frac{E-(n-2)I}{2(n-2)}.$$

You can find on this site also some posts about generalization of this question - with the values $\pm1$ replaced by some two real numbers. (I guess it is clear that approaches at least from some of the answers should also work more generally.) For example: Inverse of constant matrix plus diagonal matrix