# Inverse of a matrix with $a+1$ on the diagonal and $a$ in other places

Let $a>0$. Let $A$ be the $n\times n$ matrix with $a+1$ on the diagonal and $a$ in all other entries. How can one compute $A^{-1}$ as a function of $n$?

-

Write $A$ as $I + aJ$ where $J$ is the matrix consisting of all $1$s. Now using the fact that $J^2 = nJ$, look for an inverse of the form $c_1I + c_2J$. More generally, there is the famous Sherman-Morrison formula for rank-one perturbations of invertible matrices.
Let $J$ be an $n$ by$n$ matrix all whose entries are 1. Then the answer is $I-aJ/(1+an)$. as you can verify. To motivate and get to this formula look up a series expansion for $(I-A)^{-1}$.