Determinant of a matrix with specific main diagonal Determine the determinant of the following matrix:
$$A = \begin{pmatrix}1+a_1 &1 &\cdots &1 \\
1 &1 +a_2&\ddots& \vdots \\
\vdots & \ddots &\ddots&1 \\
1 & \cdots &1& 1 +a_n
\end{pmatrix}, a_i \in \mathbb R, i=1,2,\ldots, n.$$
My attempt:
Set $I = \{ i \mid a_i =0 , i=1,\ldots,n\}$. I found that
$$\det A = \begin{cases} 
0 \text{ if } |I| \ge 2 \\\\
\prod_{j=1, j\ne i}^n a_j \text{ if } |I| =1 \\\\
\prod_{j=1}^n a_j\left( 1+ \sum_{j=1}^n \dfrac1{a_j} \right) \text{ if } |I| =0.
\end{cases}.$$
However I am given a different answer. Any comment would be appreciated. 
 A: Clearly the answer should be totally symmetric in the $a_i$, but this is one of those annoying problems where we seem to have to live without the symmetry to actually solve it.
Your first line is obviously correct, since you have two of the same row.
If, WLOG, $a_1=0$ and the others nonzero, you use row operations to subtract the first row from every other row, which gives you a lower diagonal matrix, and I agree with your second answer.
Now if $a_1 \neq 0$, doing the same thing gives you
$$ \det{A} = \begin{vmatrix}
1+a_1 & 1 & 1 & \cdots & 1 \\
-a_1 & a_2 & 0 & \cdots & 0 \\
-a_1 & 0 & a_3 & \cdots & 0 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
-a_1 & 0 & 0 & \cdots & a_n
\end{vmatrix} $$
Now you can divide the $i$th column by $a_i$ and add it to the first row to give
$$ \left(1+a_1+ a_1\sum_{i=2}^n \frac{1}{a_i}\right)\left( \prod_{i=2}^n a_i \right) = \left( \prod_{i=1}^n a_i \right) \left( 1 + \sum_{j=1}^n a_i \right), $$
which agrees with your answer. To get rid of the divisions, you can multiply through to get
$$ \left( \prod_{i=1}^n a_i \right) + \sum_{j=1}^n \prod_{i \neq j} a_i, $$
i.e. the product of all the $a_i$ plus the symmetric polynomial of degree $n-1$ in the $a_i$, so for example for $n=3$,
$$ \det{A} = a_1 a_2 a_3 + a_1 a_2 + a_2 a_3 + a_3 a_1 $$
This formula in this form still works for the zero cases: note that if two are zero, then all the products are zero because each only excludes one factor, and if one is zero, then the only one to survive is indeed the product that excludes it.
