# Determinant of $n \times n$ matrix given diagonal and non diagonal entries

Let $$M$$ be a real $$n\times n$$ matrix with all diagonal entries equal to $$r$$ and all non-diagonal entries equal to $$s$$. Compute the determinant of $$M$$. This was a question from ISI M.Math test $$2021$$.

My attempt: I tried directly computing for small $$n$$ to see if there are any patterns. For $$n=1,2,3$$ the determinants are respectively $$r, r^2-s^2, r^3+2s^3-3rs^2$$. I couldn't find any pattern other than the obvious fact that there has to an entry $$r^n$$ for each $$n$$ so that the identity matrix satisfies the formula. And the sum of the coefficients must be zero for $$n>1$$ (by having a matrix with all entries equal to $$1$$). But I can't proceed any further.

• See Andrea's answer in math.stackexchange.com/questions/84206/… Commented Aug 15, 2023 at 5:23
• $M=(r-s)I_n+see^T$ where $e$ denotes the vector of ones. It follows that you can determine the eigenvalues of $M$ if you can determine the eigenvalues of $A=ee^T$. Since $A$ is a rank-one matrix, it has $n-1$ zero eigenvalues and the remaining eigenvalue is equal to the trace of $A$. Commented Aug 15, 2023 at 5:25
• The decomposition just given by @user1551 is a "Rank-one update of a scalar matrix". A Google search with this type of query will bring you many answers such as this one. Commented Aug 15, 2023 at 5:29
• en.wikipedia.org/wiki/Circulant_matrix#Determinant Commented Aug 15, 2023 at 6:27
• Thank you everyone
– user1161494
Commented Aug 15, 2023 at 6:41

Let $$M$$ be a real $$n\times n$$ matrix with all diagonal entries equal to $$r$$ and all non-diagonal entries equal to $$s$$. Compute the determinant of $$M$$.

I would rewrite $$M=(r-s)I+A$$ where $$A$$ is a matrix whose entries are identically $$s$$.

Now, it is easy to check that eigenvalues of $$A$$ are

• $$0$$ (by linear dependence of rows) and
• $$ns$$ (by constant row sum)

with algebraic multiplicities $$n-1$$ and $$1$$ respectively.

The eigenvalues of $$(r-s)I+A$$ will be $$(r-s)+0$$ and $$(r-s)+ns$$ with same multiplicities.

Determinant being product of eigenvalues, we have $$\det(M)=(r-s)^{n-1}(r-s+ns)$$

The question in this post is a special case.