# Rank of the $n \times n$ matrix with ones on the main diagonal and $a$ off the main diagonal

I want to find the rank of this $n\times n$ matrix \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}

that is, the matrix whose diagonals are $1's$ and $a$ otherwise, where $a$ is any real number.

My first observation is when $a=0$ the rank is $n$ and when $a=1$ the rank is $1.$ Then I can assume $a\neq 0, 1$ and proceed row reduction to find its pivot rows. I obtain

\begin{pmatrix} 1 & a & a & \cdots & a \\ 0 & 1+a & a & \cdots & a \\ 0 & a & 1+a & \cdots & a \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & a & a & \cdots & 1+a \end{pmatrix} by subtracting the first row multiplied $a$ for each row below the first, and then divides the factor $(1-a)$, and stuck there. Any hints/helps?

• Hint: in the rest of the rows subtract the top from it and that will give you the identity with all save for the first row – Sentinel135 Mar 11 '17 at 4:02
• Without doing anything you can at least say that, if $A$ is your given matrix, then $\det A=(1+(n-1)a)(1-a)^{(n-1)}$ as is shown here. Then $\det A=0\Rightarrow \mathrm{rank}(A)<n$, and $\quad\quad\det A\ne0\Rightarrow \mathrm{rank}(A)=n$ – StubbornAtom Mar 11 '17 at 5:38
• Thanks all. And the determinant approach is amazing! – Karma Mar 11 '17 at 6:07

If you haven't figured it out yet here's the solution: if $a=1$ $\mathrm{Rank}(A)=1$ otherwise $\mathrm{Rank}(A)=n$ where $$A:= \begin{pmatrix} 1&a&a&\cdots&a\\ a&1&a&\cdots&a\\ a&a&1&\cdots&a\\ \vdots&\vdots&\vdots&\ddots&\vdots\\ a&a&1&\cdots&1 \end{pmatrix}$$

You've already shown that you know if $a\in\{0,1\}$. So as for the rest, your close to a solution. The next set of Row equations are as follows $R_i-R_1 \to R_i$ such that $1<i\leq n$. This gives the matrix,

$$A_2= \begin{pmatrix} 1&a&a&\cdots&a\\ -1&1&0&\cdots&0\\ -1&0&1&\cdots&0\\ \vdots&\vdots&\vdots&\ddots&\vdots\\ -1&0&0&\cdots&1 \end{pmatrix}$$

The next Row equation is $\frac{R_1-\sum_{i=2}^n aR_i}{1+a(n-1)}\to R_1$. This gives the matrix

$$A_3= \begin{pmatrix} 1&0&0&\cdots&0\\ -1&1&0&\cdots&0\\ -1&0&1&\cdots&0\\ \vdots&\vdots&\vdots&\ddots&\vdots\\ -1&0&0&\cdots&1 \end{pmatrix}$$

The next Row equations are $R_i+R_1\to R_i$ where $1<i\leq n$. This gives $$A_4= \begin{pmatrix} 1&0&0&\cdots&0\\ 0&1&0&\cdots&0\\ 0&0&1&\cdots&0\\ \vdots&\vdots&\vdots&\ddots&\vdots\\ 0&0&0&\cdots&1 \end{pmatrix}=I$$

Note that $\mathrm{Rank}(A)=\mathrm{Rank}(I)=n$ as desired.

Karma made note that if $a=\frac{1}{1-n}$ then $$A_3= \begin{pmatrix} 0&0&0&\cdots&0\\ -1&1&0&\cdots&0\\ -1&0&1&\cdots&0\\ \vdots&\vdots&\vdots&\ddots&\vdots\\ -1&0&0&\cdots&1 \end{pmatrix}$$

This implies that for $a=\frac{1}{1-n}$ the $\mathrm{Rank}(A)=n-1$.

• Thank you! Now I'm wondering the step $\frac{R_1-\sum_{i=2}^n aR_i}{1+a^n}\to R_1$, can you explain a bit since I obtain $(1+(n-1)a$ in the $(1,1)$ entry, if I calculate it right – Karma Mar 11 '17 at 5:28
• @karma yeah your right I need to fix that sorry – Sentinel135 Mar 11 '17 at 5:43
• So we need to consider the case when $a=\frac{1}{1-n}$ too? If $a=\frac{1}{1-n}$ then the first row is a linear combination of all the other rows, with coefficient $=\frac{1}{1-n}$ for each row. Then the rank of $A$ should be $n-1$ in this case. – Karma Mar 11 '17 at 5:57
• If $a=\frac{1}{1-n}$ then the denominator is zero, and with this value $\det(A)=0$, so rank$A\neq n$. – Karma Mar 11 '17 at 17:08
• ok yes i I was misreading your $a$ I'm going to delete my comment and edit the answer given. Thanks – Sentinel135 Mar 11 '17 at 17:15

Let

$$\mathrm 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) \mathrm I_n + a 1_n 1_n^{\top}$$

The eigenvalues of rank-$1$ matrix $a 1_n 1_n^{\top}$ are

• $\color{blue}{0}$ with multiplicity $n-1$.
• $\color{blue}{n a}$ with multiplicity $1$.

Thus, the eigenvalues of $\mathrm M_n (a) = (1-a) \mathrm I_n + a 1_n 1_n^{\top}$ are

• $\color{blue}{1-a}$ with multiplicity $n-1$.
• $(1-a) + na = \color{blue}{(n-1) \, a + 1}$ with multiplicity $1$.

We could also have arrived at this conclusion computing the characteristic polynomial of $\mathrm M_n (a)$

$$\begin{array}{rl} \det ( s \mathrm I_n - \mathrm M_n (a) ) &= \det \left( (s-(1-a)) \mathrm I_n - a 1_n 1_n^{\top} \right)\\ &= \det \left( (s-(1-a)) \left( \mathrm I_n - \frac{a}{s-(1-a)} 1_n 1_n^{\top} \right) \right)\\ &= (s-(1-a))^n \cdot \det \left( \mathrm I_n - \frac{a}{s-(1-a)} 1_n 1_n^{\top} \right)\\ &= (s-(1-a))^n \cdot \left(1 - \frac{n a}{s-(1-a)}\right)\\ &= (s-(1-a))^{n-1} \cdot \left(s-(1-a) - n a\right)\\ &= (s-(1-a))^{n-1} \cdot \left( s - ((n-1) \, a + 1) \right)\end{array}$$

where the matrix determinant lemma was used. If

$$a \in \left\{ -\frac{1}{n-1}, 1 \right\}$$

then $\mathrm M_n (a)$ is singular. Thus, using the rank-nullity theorem, we conclude that

$$\boxed{\mbox{rank} (\mathrm M_n (a)) = \begin{cases} 1 & \text{if } a = 1\\ n-1 & \text{if } a = -\frac{1}{n-1}\\ n & \text{otherwise}\end{cases}}$$