# Moore-Penrose pseudoinverse and multiplication by diagonal matrix

Let $$A \in \mathbb{R}^{n \times p}$$, let $$D$$ be a diagonal matrix with positive entries. $$\dagger$$ denotes the Moore-Penrose pseudoinverse.

Is it true in general that: $$(A^\top D A)^\dagger A^\top D = (A^\top D^2 A)^\dagger A^\top D^2 \enspace ?$$ (and if not, is it easy to determine when this holds?)

If $$D$$ is proportional to identity, ok. Multiplying by $$A$$ on the right yields an identity which looks reasonable when $$A^\top D A$$ is invertible.

Numerical simulations with $$p > n$$ give frequent equality, but not always, and I'm unable to determine in which case the equality holds.

Using the identity $$(X^\top X)^\dagger X^\top=X^\dagger$$, the equality in question can be rewritten as $$(\sqrt{D}A)^\dagger\sqrt{D}=(DA)^\dagger D$$.
It is true when $$A$$ has full row rank (but numerical verification may fail because of rounding errors). In this case, $$(BA)^\dagger=A^\dagger B^\dagger$$ for any $$B$$ with full column rank (see Wikipedia). Hence $$(\sqrt{D}A)^\dagger\sqrt{D}=A^\dagger \sqrt{D}^\dagger\sqrt{D}=A^\dagger=A^\dagger D^\dagger D=(DA)^\dagger D.$$ Alternatively, when $$A$$ has full row rank, $$(\sqrt{D}A)^\top$$ and $$(DA)^\top$$ have the same column spaces. So, using the fact that $$X^\dagger X$$ is the orthogonal projection onto the column space of $$X^\top$$, we see that $$(\sqrt{D}A)^\dagger\sqrt{D}A=(DA)^\dagger DA$$. Right-multiply both sides by the right inverse of $$A$$, we obtain $$(\sqrt{D}A)^\dagger\sqrt{D}=(DA)^\dagger D$$.