Simultaneous diagonalization of a positive semi-definite matrix and a symmetric matrix

Let $$A,B$$ be $$d\times d$$ symmetric matrices with real coefficients such that $$A$$ is positive semi-definite. Prove that $$\det(tA+B)\in \mathbb{R}[t]$$ is either $$0$$ or has all roots real.

Here is what I tried:

Let us at-first assume that $$A$$ is positive definite. Then we know that there is a non-singular matrix $$S$$ such that $$SAS^{T}=I$$ and $$SBS^{T}=\Lambda$$, where $$\Lambda$$ is some diagonal matrix. Thus the problem reduces to showing that $$\det(tI+\Lambda)$$ has real roots, but this is obvious because the roots are eigenvalues of $$\Lambda$$ and any symmetric matrix has all real eigenvalues.

However, I am stuck with the case where $$A$$ has a $$0$$ eigenvalue. My guess is that we can still find such a invertible matrix $$S$$ such that $$SAS^{T}$$ is diagonal with only $$0$$'s and $$1$$'s on the diagonal and $$SBS^{T}$$ is diagonal. But I am not sure how to prove this. Any help would be appreciated.

• Where does this come from? Jul 1 at 6:20

for some $$\lambda \in\mathbb C$$:
$$\det\big(\lambda A + B\big)=0\implies \lambda A\mathbf x =-B\mathbf x$$ for some $$\mathbf x \in \mathbb C^d-\big\{\mathbf 0\big\}$$
case 1: $$\mathbf x \not \in \ker A\implies \mathbf x^* A \mathbf x \neq 0$$ (since $$A$$ is PSD)
line 2 $$\implies \lambda \cdot\mathbf x^* A\mathbf x =-\mathbf x^*B\mathbf x= \big(\lambda \cdot\mathbf x^* A\mathbf x\big)^*=\overline \lambda \cdot\mathbf x^* A\mathbf x$$
$$\implies \lambda \in \mathbb R$$
case 2: $$\mathbf x \in \ker A$$
line 2:$$\implies \mathbf 0 = \lambda A\mathbf x =-B\mathbf x \implies \mathbf x \in \ker B$$
hence for any $$\lambda \in \mathbb C$$ we have $$\big(\lambda A+B\big)\mathbf x=\mathbf 0\implies \det\big(\lambda A+B\big)=0$$
$$\implies \det(tA+B)\in \mathbb{R}[t]$$ has an infinite number of roots, i.e. is the zero polynomial.