Solution (source code)

= Solution

For a rectangular diagonal matrix $D$, define $D^+\in\mathbb R^{n\times m}$ by transposing its shape and taking
$$
\boxed{(D^+)_{ii}=\begin{cases}D_{ii}^{-1},&D_{ii}\ne0,\\0,&D_{ii}=0,\end{cases}\qquad(D^+)_{ij}=0\ (i\ne j).}
$$
Entry by entry, $DD^+D=D$ and $D^+DD^+=D^+$. For $A=U\Sigma V^T$, orthogonality therefore gives
$$
\boxed{A^+=V\Sigma^+U^T,}
$$
since $AA^+A=U\Sigma\Sigma^+\Sigma V^T=A$, and similarly $A^+AA^+=A^+$. This candidate is the <Moore-Penrose inverse>. It also makes $AA^+$ and $A^+A$ symmetric, although those two extra conditions are not required by the question's stated definition. The two displayed conditions alone need not specify a unique generalized inverse.