# Inverting a matrix with the same diagonal entries in a particular form

Hi I'm struggling with this inversion and any help would be greatly appreciated.

I want to invert the following $$\mathbb R^{m\times m}$$ matrix $$\begin{bmatrix} 1 + m & m & \dots & \dots & m \\ m & 1+m & m & \dots & m\\ \dots & \dots &\dots & \dots & \dots\\ m & m & m & \dots & 1 +m \end{bmatrix}$$ such that it is of the following form: $$I - \gamma \textbf{u}\textbf{u}^T$$ for a constant $$\gamma$$ that I need to find, and $$\textbf{u} = \begin{bmatrix} 1 \\ 1 \\ \vdots \\ 1 \end{bmatrix} \in \mathbb R^m.$$

So the matrix to invert is square and has $$1+m$$ in all its diagonal entries and $$m$$ everywhere else, not sure if there is a special way to invert such a matrix. Thanks.

The solution is $$\gamma=\frac{m}{m^2+1}$$.
When writing out the product of the matrix that needs to be inverted with the proposed form of the inverse: $$$$\begin{bmatrix} 1 + m & m & \dots & m \\ m & 1+m & \ddots & \vdots\\ \vdots & \ddots &\ddots & m\\ m & \dots & m & 1 +m \end{bmatrix} \begin{bmatrix} 1-\gamma & -\gamma & \dots & -\gamma \\ -\gamma & 1-\gamma & \ddots & \vdots\\ \vdots & \ddots &\ddots & -\gamma\\ -\gamma & \dots & -\gamma & 1-\gamma \end{bmatrix} = \begin{bmatrix} 1 & 0 & \dots & 0 \\ 0 & 1 & \ddots & \vdots\\ \vdots & \ddots &\ddots & 0\\ 0 & \dots & 0 & 1 \end{bmatrix}$$$$ you'll notice that for each diagonal element of the resulting identity matrix, you have $$$$(1+m)(1-\gamma) + (m-1) m (-\gamma) = 1$$$$ while on the off-diagonal, you have $$$$m (1-\gamma) + (1+m)(-\gamma) + (m-2)m(-\gamma) = 0$$$$ Both equations have the same solution for $$\gamma$$, namely $$\gamma=\frac{m}{m^2+1}$$.