# Find the inverse of a matrix with a variable

$$X= \begin{pmatrix} 2-n & 1 & 1 & 1 & \ldots & 1 & 1 \\ 1 & 2-n & 1 & 1 & \ldots & 1 & 1 \\ \vdots & \vdots & \vdots & \vdots & \ddots & \vdots & \vdots \\ 1 & 1 & 1 & 1 & \ldots & 2-n & 1 \\ 1 & 1 & 1 & 1 & \ldots & 1 & 2-n\end{pmatrix}_{n\times n}$$

Which means that the matrix with the size of $n\times n$ have $n-2$ along the diagonal and $1$ everywhere else. Help please, I am stuck with this problem.

• How is this matrix infinite if you say it is $n\times n$? – DKal Nov 10 '13 at 11:52
• sorry, I dont know how that infinite got there. editing right away. – Wanderer Nov 10 '13 at 11:53

HINT: Let $B$ be the $n\times n$ matrix of ones. Then $XB=B$, so

$$X(B-I)=XB-X=B-X=(n-1)I\;,$$

where $I$ is the $n\times n$ identity matrix.

By the way, manually calculating the inverses for $n=2$ and $n=3$ was enough to suggest what the answer ought to be, and discovering the argument suggested above was then quite easy.

• I took the liberty of naming the matrix in the question as $X$, in the question. – Git Gud Nov 10 '13 at 12:11
• @GitGud: Thanks for letting me know. – Brian M. Scott Nov 10 '13 at 12:13

Hint: Use the Sherman–Morrison formula on $$X=\text{diag}(1-n)_{n\times n}+\begin{pmatrix} 1\\ \vdots \\1\end{pmatrix}_{n\times 1}\begin{pmatrix}1 & \ldots &1 \end{pmatrix}_{1\times n}.$$

If you see in terms of systems rather than matrices, you must solve

$X(x_1,x_2,\ldots,x_n)=(y_1,y_2,\ldots,y_n)$ where the $y_i$ are given

and the $x_i$ are the unknowns.

$$x_1+x_2+\ldots +x_n=y_1+y_2+\ldots y_n (1)$$
Then, comparing (1) with the $i$-th equation gives you the value of $x_i$.