How to show a $3\times3$ matrix has three distinct eigenvalues? Here is a question I heared from others:
Given four distinct positive real numbers $a_1,a_2,a_3,a_4$ and set $$a:=\sqrt{\sum_{1\leq i\leq 4}a_i^2}$$
$A=(x_{i,j})_{1\leq i\leq3,1\leq j\leq4}$ is a $3\times4$-matrix specified by $$ x_{i,j}=a_i\delta_{i,j}+a_j\delta_{4,j}-\frac{1}{a^2}(a_i^2+a_4^2)a_j $$
where $\delta_{i,j}$ is the Kronecker symbol or visually
$$ A=\begin{pmatrix}a_1 &0&0&a_4\\ 0&a_2&0&a_4\\0&0&a_3&a_4\end{pmatrix}-\frac{1}{a^2}
\begin{pmatrix} 
a_1(a_1^2+a_4^2) & a_2(a_1^2+a_4^2) & a_3(a_1^2+a_4^2) & a_4(a_1^2+a_4^2)\\
a_1(a_2^2+a_4^2) & a_2(a_2^2+a_4^2) & a_3(a_2^2+a_4^2) & a_4(a_2^2+a_4^2)\\
a_1(a_3^2+a_4^2) & a_2(a_3^2+a_4^2) & a_3(a_3^2+a_4^2) & a_4(a_3^2+a_4^2)\\
\end{pmatrix} $$
The question is to show that the $3\times3$-matrix $B=AA^T$ admits three distinct eigenvalues.($A^T$ is the transpose of $A$)
What I am curious about is how many methods can be utilized to show a matrix has different eigenvalues?
As for this question my idea is to calculate the characteristic polynomial $f$ of $B$ along with $f'$ which is a quadratic polynomial via Sagemath and show that neither of roots of $f'$ belongs to $f$. Or equivalently to calculate the resultant $R(f,f')$ of $f$ and $f'$ and show that $R(f,f')$ doesn't vanish for any distinct positive $a_i$'s.
But the difficulties are both ways involve hideous calculation which I don't think I can write down by hand. So I'm wondering if there is a tricky way to get to that point? (e.g. an algebraic-geometry method?)
 A: Here is an explicit solution found computationally (and then beautified) using the approach referenced by Dima.
Let
$$f(x,y,z,t) := (x-y) (z-t) (xy(z+t) - (x+y)zt),$$
$$g(x,y,z,t) := (x-y) (z-t) (xy(z-t) + (x-y)zt).$$
Then the discriminant in question equals
$$2a^{-8}(7s_1 + s_2),$$
where
$$s_1:= f(a_1^2,a_2^2,a_3^2,a_4^2)^2 + f(a_1^2,a_3^2,a_2^2,a_4^2)^2 + f(a_2^2,a_3^2,a_1^2,a_4^2)^2$$
and
$$s_2:= g(a_1^2,a_2^2,a_3^2,a_4^2)^2 + g(a_1^2,a_3^2,a_2^2,a_4^2)^2 + g(a_2^2,a_3^2,a_1^2,a_4^2)^2 + g(a_3^2,a_2^2,a_1^2,a_4^2)^2 + g(a_1^2,a_1^2,a_3^2,a_4^2)^2 + g(a_3^2,a_1^2,a_2^2,a_4^2)^2.$$
(Btw, it can be verified that both $s_1$ and $s_2$ represent symmetric polynomials in $a_1^2,a_2^2,a_3^2,a_4^2$.)
Now, we see that the discriminant as the sum of squares can be zero only when all these squares are zero. Since $a_i$ are pairwise distinct, we can cancel the first two (linear) factors in $f,g$ and focus on third factors being zero. However, in the ideal generated by these factors, there is a polynomial (I checked the first one in the Grobner basis) that is nonzero for distinct nonzero $a_i$, meaning that all squares cannot be zero at the same time.
So, the discriminant is strictly positive.
PS. In fact, $s_2$ alone cannot be zero for pairwise distinct $a_i$.
A: To answer on methods applicable here (and elaborate on comments I made). The most promising is to use a surprisingly little-known theorem that says that the discriminant $D$ of a symmetric $n\times n$ matrix $A=(a_{ij})$ with eigenvalues $\lambda_1,\dots,\lambda_n$, i.e.
$$ D_A=\prod_{1\leq i<j\leq n} (\lambda_i-\lambda_j)^2,$$
is a sum of squares in the ring $\mathbb{R}[a_{11},a_{12},\dots,a_{nn}]$ (notice that $D_A$ is nonnegative, as all $\lambda_k$ are real).
This has been proved independently by a number of authors, e.g. in a paper by P.Lax.
An explicit formula for such an expression for $n=3$ may be found in Sect. 4 of B.Parlett's
paper.
This is a rather surprising result for everyone familiar with the fact that most nonnegative multivariate polynomials are not sums of squares (this topic has history going back to a famous paper by Hilbert from 1888).
A: This question is from this year's Alibaba mathematics competition (qualifying round, which is finished 2 days ago), and here's my solution that could be wrong (I also participated in the competition and this is the solution I submitted). I tried to solve the problem geometrically to avoid tons of computations.

First, we can deal with $A^{T}A$ instead of $AA^{T}$ since the first matrix's eigenvalues is same as the second eigenvalue's matrix with zero (consider SVD of $A$). The key point is that $A$ can be written as $A = BP$ where
$$
B = \begin{pmatrix} a_1 & 0 & 0 & a_4 \\ 0 & a_2 & 0 & a_4 \\ 0 & 0 & a_3 & a_4 \end{pmatrix}
$$
and
$$
P = I_3 - \mathbf{v}\mathbf{v}^{T}, \mathbf{v} = \frac{1}{a}(a_1, a_2, a_3, a_4)^{T}. 
$$
Especially, the matrix $P$ is an orthogonal projection matrix that project a vector in $\mathbb{R}^{4}$ to the subspace of vectors that are perpendicular to $\mathbf{v}$. It satisfies $P^{T} = P^{2} = P$.
To show that the eigenvalues are distinct, we will show that each eigenspace (for nonzero eigenvalues) has dimension 1. In other words, for a given eigenvalue, there exists a unique eigenvector (up to constant factor) corresponding to the eigenvalue.
First, the above $\mathbf{v}$ is an eigenvector of $A^{T}A$ correspond to the eigenvalue 0 since $A\mathbf{v} = BP\mathbf{v} = \mathbf{0}$. Since the eigenvectors are orthogonal to each other, the other three eigenvectors are in the image of $P$ (the hyperplane perpendicular to $\mathbf{v}$). If we fix an (nonzero) eigenvalue $\lambda$ and a corresponding eigenvector $\mathbf{w}$, we have $P\mathbf{w} = \mathbf{w}$ and so
$$
A^{T}A\mathbf{w} = PB^{T}BP\mathbf{w} = PB^{T}B\mathbf{w} = \lambda \mathbf{w}.
$$
From this, the vector $B^{T}B\mathbf{w}$ should be written as
$$
B^{T}B\mathbf{w} = \lambda \mathbf{w} + \beta \mathbf{v}
$$
for some $\beta$. If we set $\mathbf{w} = (x_1, x_2, x_3, x_4)^{T}$, then expanding the above equation gives
$$
\begin{pmatrix}a_1^2 & 0 & 0 & a_{1}a_{4} \\ 0 & a_{2}^{2} &  0 & a_{2}a_{4} \\ 0 & 0& a_{3}^{2} & a_{3}a_{4} \\ a_{1}a_{4} & a_{2}a_{4} & a_{3}a_{4} & 3a_{4}^{2} \end{pmatrix}\mathbf{w} = \begin{pmatrix} a_{1}^{2}x_{1} + a_{1}a_{4}x_{4} \\ a_{2}^{2}x_{2} + a_{2}a_{4}x_{4} \\ a_{3}^{2}x_{3} + a_{3}a_{4}x_{4} \\ a_{4}(a_{1}x_{1} + a_{2}x_{2} + a_{3}x_{3} + 3a_{4}x_{4})\end{pmatrix} = \begin{pmatrix} a_{1}^{2}x_{1} + a_{1}a_{4}x_{4} \\ a_{2}^{2}x_{2} + a_{2}a_{4}x_{4} \\ a_{3}^{2}x_{3} + a_{3}a_{4}x_{4} \\ 2a_{4}^{2}x_{4}\end{pmatrix}  = \begin{pmatrix} \lambda x_1 + \beta' a_1 \\ \lambda x_2 + \beta' a_2 \\ \lambda x_3 + \beta' a_3 \\ \lambda x_4 + \beta' a_4\end{pmatrix}, \quad \beta' = \frac{\beta}{a}
$$
Here we used $\langle \mathbf{v}, \mathbf{w} \rangle = a_{1}x_{1} + \cdots + a_{4}x_{4} = 0$ for the second equality. From this, we can show that $x_{4}$ should be nonzero (here's the point that distinctiveness of $a_i$'s are used), so we can assume that $x_4 = 1$ and the other components $x_1, x_2, x_3$ are uniquely determined. This proves our claim that each eigenspace has dimension 1, i.e. the eigenvalues are distinct.
