If $A$ is a symmetric matrix and if $P$ and $Q$ are non-singular matrices such that $P'AP$ and $Q'AQ$ are diagonal matrices, then show that the number of positive diagonal elements in the two diagonal matrices is the same.
I don't know how to prove the above. Please anyone help me solve it. Thanks in advance.
Let $D = P' A P$ and $\tilde{D} = Q' A Q$. These are two diagonal matrices such that $\tilde{D} = B'DB$ with $B = P^{-1} Q$.
I claim that the number of positive entries of $D$ can be characterized in the following way.
Assume this is true for now. If $S$ is a subspace such that $v' D v > 0$ for any nonzero $v \in S$, then $B^{-1}S := \{B^{-1}w : w \in S\}$ is a subspace such that $v' \tilde{D} v > 0$ for any nonzero $v \in B^{-1}S$; moreover $\dim S = \dim B^{-1}S$ because $B^{-1}$ is invertible.
Conversely, if $S$ is a subspace such that $v' \tilde{D} v > 0$ for any nonzero $v \in S$, then $BS := \{Bw : w \in S\}$ is a subspace such that $v' D v > 0$ for any nonzero $v \in BS$; also, $\dim S = \dim BS$.
This correspondence between subspaces on which $D$ is positive definite and subspaces on which $\tilde{D}$ is positive definite implies that the maximum dimensions are the same, and by the above claim the number of positive diagonal entries are the same.
Proving the claim: let the diagonal entries of $D$ be $d_1, \ldots, d_n$. Then $v' D v = \sum_{i=1}^n d_i v_i^2$. Consider the subspace $S_+ := \{v : v_i = 0 \text{ if $d_i \le 0$}\}$. Note $\dim S_+$ equals the number of positive entries of $D$, and moreover $v' D v = \sum_{i=1}^n d_i v_i^2 > 0$ for nonzero $v \in S_+$ because each addend is either zero (because $v_i^2 =0$) or strictly positive (because $d_i > 0$). This proves $$\text{number of positive entries of $D$} \le \max\{\dim S : \text{subspace $S$ s.t. $v' D v > 0$ for all nonzero $v \in S$}\}.$$
To prove that it inequality is actually equality, we need to show that any subspace $S$ with dimension bigger than $\dim S_+$ cannot satisfy $v'Dv>0$ for all nonzero $v \in S$. Suppose $\dim S > \dim S_+$. Then $S$ must intersect $S_+^\perp = \{v : v_i = 0 \text{ if } d_i > 0\}$ nontrivially (else $S$ would be a subspace of $S_+$, which is impossible if $\dim S > \dim S_+$). So there is some nonzero $v \in S \cap S_+^\perp$, in which case $v' D v = \sum_{i=1}^n d_i v_i^2 \le 0$ (since for each $i$, either $d_i \le 0$ or $v_i = 0$). Thus we have found an element of $S$ such that $v' D v \not> 0$.