I've come across the question of finding the determinant of the $(n\times n)$ matrix, given by
$$A:= \begin{pmatrix} x & 1 & 1 & \dots & 1 \\ 1 & x & 1 & \dots & 1 \\ \vdots && \ddots & & \vdots \\ 1 & \dots & \dots & x & 1\\ 1 &\dots & \dots & 1&x^2 \end{pmatrix}$$
for all $x \in \mathbb R$ and for all $n\geq2$. I know that the answer is $$\det A =(x-1)^{n-1} \cdot (x^2+(n-1) x+n-1) \tag 1$$
and I can prove it by induction if I'm allow to make some hand-wavy assumptions, which I'm not allowed to do because it was an exam question of a pure maths class (linear algebra). However I think that I'm missing something because without having a computer algebra system, coming up with the equation $(1)$ is hard enough, let alone the two inductions I need to do in order to show the equation $(1)$ with some hand-wavy assumptions, which makes the question way too hard for a 2 hour exam.
Is there an easier way to calculate this determinant?
You add up all the rows to the first one giving x + n-1 for all but the n-th element, which is x² + n-1.
Then you factor out the x + n-1 (with the condition that it isn't zero, prove the trivial case separately; the general solution also holds for x=-n+1), so the first row becomes all ones except for the n-th entry.
Then you subtract the first row from all the others getting an upper triangular matrix with a (1, x-1, ..., x-1, x²-(x²+n-1)/(x+n-1)) main diagonal.
Now the determinant of a triangular matrix is the product of the elements in its main diagonal.
So we have detAₙ = (x+n-1) (x-1)^(n-2) (x²-(x²+n-1)/(x+n-1)) = (x−1)^(n−1) (x²+(n−1)x+n−1).