Trace of product of orthogonal projectors is an inner product $\operatorname{tr}(\pi_{x'}\pi_{y'}) = |\langle y,x\rangle|^2$ I am reading something in quantum mechanics, and it has the following claim.
Setting: Consider a complex vector space $\mathbb{C}^k$, its projective space $P(\mathbb{C}^k)$. For nonzero $x \in \mathbb{C}^k$, we denote $x'$ the corresponding equivalence class of $x$ in $P(\mathbb{C}^k)$. We also consider the set of density matrices
$D_k = \{\rho \in M_k(\mathbb{C})| \rho \geq 0, \text{tr }\rho = 1\}$ where $M_k(\mathbb{C})$ is the set of $k \times k$ complex matrices. The set $D_k$ is in one-to-one correspondence with the projective space by the bijection
$$
P(\mathbb{C}^k) \ni x' \mapsto \pi_{x'} \in D_{x'}
$$
with $\pi_{x'}$ the orthogonal projector on the corresponding ray in $\mathbb{C}^k$.
Claim. $$\operatorname{tr}(\pi_{x'}\pi_{y'}) = |\langle y,x\rangle|^2$$
I am not sure why this is true.
 A: It's a straightforward computation, assuming that $x,y$ are unit vectors. The projection $\pi_{x'}$ is the operator
$$
\pi_{x'}z=\langle z,x\rangle\,x.
$$
Then
$$
\pi_{x'}\pi_{y'}z=\langle z,y\rangle\pi_{x'}y=\langle z,y\rangle\langle y,x\rangle \,x.
$$
In particular,
$$
\pi_{x'}\pi_{y'}x=|\langle x,y\rangle|^2\,x.
$$
Now form an orthonormal basis $\{x,e_2,\ldots,e_n\}$, and calculate the trace along that basis:
$$
\operatorname{tr}(\pi_{x'}\pi_{y'})=|\langle x,y\rangle|^2\langle x,x\rangle=|\langle x,y\rangle|^2.
$$
A: I am going to treat it with matrices.
Let us assume that $x$ and $y$ are unit vectors.
It is known that the projection onto vector $x$ has this matrix representation :
$$\pi_x=XX^H=\begin{pmatrix}x_1\\x_2\\  \vdots \\ x_n\end{pmatrix}(x_1 \ \ x_2 \ \ \cdots \ x_n)^H$$
where $^H$ means conjugate-transpose operation.
Therefore :
$$\pi_x \pi_y=(XX^H)(YY^H)^*=X\underbrace{(X^HY)}_{\in \ \mathbb{C}}Y^H=(X^HY)(XY^H)\tag{1}$$
(the last expression is obtained by taking the number $X^HY$ out of the matrix product).
(1) appears as the product of a complex number by a matrix whose diagonal entries are the $x_ky_k^*$ ($k=1,2...n$, where $^*$ denotes the conjugation operation) ; the sum of these entries is $XY^H$ which is precisely the conjugate of $X^HY$.
Therefore taking the trace of LHS and RHS of (1) gives the result.
