Find the inverse of the $n \times n$ matrix with ones on the main diagonal and $a$ off the main diagonal

I want to find the inverse of this $$n\times n$$ matrix, assuming it is invertible. The condition of invertible is discussed at Rank of the $n \times n$ matrix with ones on the main diagonal and $a$ off the main diagonal.

Now assume it is invertible. I need to find the inverse.

$$\begin{pmatrix} 1 & a & a & \cdots & \cdots & a \\ a & 1 & a & \cdots & \cdots & a \\ a & a & 1 & a & \cdots & a \\ \vdots & \vdots & a& \ddots & & \vdots\\ \vdots & \vdots & \vdots & & \ddots & \vdots \\ a & a & a & \cdots &\cdots & 1 \end{pmatrix}$$

• Sometimes they write capital $J$ for the square matrix with all entries $1.$ Then $J^2 = n J, \;$ and you can try to find $x,y$ so that $(xI + y J) ( (1-a)I + a J) = I.$ Commented Sep 27, 2022 at 2:14
• @WillJagy so there is no closed form of the inverse matrix? Commented Sep 27, 2022 at 2:50
• do me a favor, expand $(xI + yJ)((1-a)I + a J )$ and give the final coefficients of $I$ and $J$ Commented Sep 27, 2022 at 2:53
• @WillJagy I get 2 equations. $x(1-a)=1$ and $xa+y-ya+yan=0$ Commented Sep 27, 2022 at 3:02
• So, given $a \neq 1,$ what are $x$ and $y?$ Commented Sep 27, 2022 at 3:05

$${\bf M}_n (a) := \begin{bmatrix} 1 & a & a & \dots & a & a\\ a & 1 & a & \dots & a & a\\ a & a & 1 & \dots & a & a\\ \vdots & \vdots & \vdots & \ddots & \vdots & \vdots\\ a & a & a & \dots & 1 & a\\ a & a & a & \dots & a & 1\end{bmatrix} = (1-a) {\bf I}_n + a {\bf 1}_n {\bf 1}_n^{\top}$$

Using Sherman-Morrison,

$${\bf M}_n^{-1} (a) = \cdots = \color{blue}{\frac{1}{1 - a} \left( {\bf I}_n - \frac{a}{1 + (n-1) a} {\bf 1}_n {\bf 1}_n^{\top} \right)}$$

which is the matrix that Greg obtained via other means.

If $$\def\o{{\tt1}}J$$ is the $$(n\times n)$$ all-ones matrix, then $$P=\frac{\o}nJ$$ is a projector, i.e. $$P^2=P.$$

There is a general formula for functions of such matrices: $$\def\a{\alpha}\def\b{\beta}\def\l{\lambda} \def\LR#1{\:\left[#1\right]} f(\l P+\b I) = f(\l+\b)\,P + f(\b)\,(I-P)$$ The matrix in question can be written as \eqalign{ A &= aJ + (\o-a)\,I \\ &= (an)\,P + (\o-a)\,I \\ &\equiv \l P + \b I \\ } Choosing $$\:f(A)=A^{-1}\:$$ yields \eqalign{ A^{-1} &= \frac{P}{\l+\b} + \frac{I-P}{\b} \\ &= \frac{\o}{\b}\LR{I-\frac{\l P}{\l+\b}} \\ &= \frac{\o}{\o-a}\LR{I-\frac{aJ}{an-a+\o}} \\ }

• @RodrigodeAzevedo It's from Chapter 1 of Higham's Functions of Matrices $\,$ (I can't remember if it's shown as a theorem or as one of the problems in the appendix)
– greg
Commented Oct 2, 2022 at 14:54
• Thank you. When you can find some time, please consider providing a reference to Higham's book. Commented Oct 2, 2022 at 14:58