# Does the multiplication by diagonal matrix preserve the signs of eigenvalues?

My question is as follows:

Let $$A$$ be a real symmetric $$n\times n$$ matrix and $$D=\mathrm{diag}(d_1,\ldots,d_n)$$ be a diagonal matrix whose diagonal entries are all positive real numbers(denoted as $$d_1,\ldots,d_n$$). If $$A$$ has $$k$$ positive eigenvalues, $$m$$ zero eigenvalues(i.e. $$0$$ is an eigenvalue with multiplicity $$m$$) and $$n-m-k$$ negative eigenvalues. Then does $$DA$$ have the same number of positive, zero, negative eigenvalues?

Intuitively, I think this statement is true because, heuristically, if we assume that $$A$$ is also diagonal, its diagonal entries are exactly the eigenvalues of $$A$$, and the identity $$\mathrm{diag}(d_1,\ldots,d_n)\cdot \mathrm{diag}(a_1,\ldots,a_n)=\mathrm{diag}(a_1d_1,\ldots,a_nd_n)$$ directly gives the result. Also it is well-known that the statement is true if $$A$$ is positive semi-definite. However, I'm not sure that this is also true for the general cases where $$A$$ is not necessarily positive semi-definite. I tried to find a counterexample, but it also didn't work.

Does anyone have ideas?

Yes. Since $$B=D^{1/2}AD^{1/2}$$ is congruent to $$A$$, they have the same inertia, by Sylvester's law of inertia. However, $$B$$ is similar to $$D^{1/2}BD^{-1/2}=DA$$. Therefore $$DA$$ also has the same number of positive/zero/negative eigenvalues as $$A$$.