Finding the inverse of a symmetric $28\times28$ matrix

Solution 1:

Here is an another way:

Note that $A=29I - e e^T$, where $e$ is a vector of ones. It is straightforward to check that the eigenvalues are $1,29$ hence it is invertible.

To compute $A^{-1}$, solve $Ax=b$.

This is $29x-(e^Tx)e = b$, hence $29 e^T x -(e^Tx)e^T e = e^T b $, or $e^T x = e^T b$. The first equation can be written as $29 x = (e^T b)e+b=(I+e e^T)b $, and so $x = {1 \over 29} (I+e e^T)b $, from which we get $A^{-1} = {1 \over 29} (I+e e^T)$.

Solution 2:

More generally, let

$$ {\bf A} := (n+1) \, {\bf I}_n - {\bf 1}_n {\bf 1}_n^\top $$

Note that $\bf A$ is a rank-$1$ update of a multiple of the identity matrix. Using Sherman-Morrison,

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