# Determinant of $n\times n$ Matrix Linear Algebra

So, I have a matrix
$$A = \begin{pmatrix} 0 & 1 & 1 & ... & 1 \\ 1 & 0 & x & ... & x \\ 1 & x & 0 & ... & x \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & x & x & ... & 0 \end{pmatrix}$$ I need to evaluate it's determinant. At first I calculated $$\det A$$ for $$n=2,3,4$$. And I got a pattern $$\det A=(-1)^{n-1}(n-1)x^{n-2}$$ for every $$n\ge2$$. But I need to solve it differently. I added all rows to the first, then multiplied every row (except 1) by $$(1+x(n-2))$$ and subtracted first row multiplied by $$x$$. This is what I got: $$\begin{pmatrix} n-1 & 1+x(n-2) & 1+x(n-2) & ... & 1+x(n-2) \\ 1-x & -x(1+x(n-2)) & 0 & ... & 0 \\ 1-x & 0 & -x(1+x(n-2)) & ... & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1-x & 0 & 0 & ... & -x(1+x(n-2)) \end{pmatrix}$$ Now I can multiply diagonal elements, but I don't know what can I do with the rest of it. Any hints will be helful.

First factor out $$1+x(n-2)$$ from all columns except the first to get $$\det A(x)=\begin{vmatrix} n-1 & 1 & 1 & \cdots & 1 \\ 1-x & -x & 0 & \cdots & 0 \\ 1-x & 0 & -x & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1-x & 0 & 0 & \cdots & -x \end{vmatrix}$$ and note that this cancels the multplication by $$(1+x(n-2))^{n-1}$$ from before. Now multiply the first column by $$x$$ and the rest of them by $$(1-x)$$ and then add them all to the first one: $$\det A(x)=\frac1{x(1-x)^{n-1}}\begin{vmatrix} n-1 & 1-x & 1-x & \cdots & 1-x \\ 0 & -x(1-x) & 0 & \cdots & 0 \\ 0 & 0 & -x(1-x) & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \cdots & -x(1-x) \end{vmatrix}$$
$$\det A = \frac{(n-1) (-x(1-x))^{n-1}}{x(1-x)^{n-1}} = (-1)^n(n-1)x^{n-2}.$$
Note that this calculation was assuming that $$x \notin \left\{0,1,-\frac1{n-2}\right\}$$ so these cases should be considered separately. Alternatively, $$\det A(x)$$ is a continuous function in $$x$$ equal to $$(-1)^n(n-1)x^{n-2}$$ on the dense set $$\Bbb{R}\setminus \left\{0,1,-\frac1{n-2}\right\}$$ so it must be $$\det A(x) = (-1)^n(n-1)x^{n-2}$$ everywhere.