Projection matrix onto null space I have a matrix $H$ and I want to find the projection matrix onto null space. How can I do this?
 A: Let $H \in \mathbb{F}^{m \times n}$ for $\mathbb{F} = \mathbb{R}$ or $\mathbb{F} = \mathbb{C}$. If I understood you right, you want $P \in \mathbb{F}^{n \times n}$ of a maximum rank such that


*

*$HP = 0$,

*$P^2 = P$.


Let $H = U \Sigma V^*$ be an SVD of $H$, where $U$ and $V$ are unitary or orthogonal, depending on $\mathbb{F}$, of order $m$ and $n$, respectively, and
$$\Sigma = \mathop{\rm diag}(\sigma_1, \dots, \sigma_k) \in \mathbb{R}^{m \times n}, \quad \sigma_1 \ge \cdots \ge \sigma_p > \sigma_{p+1} = \cdots \sigma_k = 0, \quad k = \min\{m,n\}.$$
Let $\Sigma' := \mathop{\rm diag}(\sigma_1', \dots, \sigma_n') \in \mathbb{R}^{n \times n}$ such that
$$\sigma_i' = \begin{cases}
0, & i \le p, \\
1, & i > p.
\end{cases}.$$
Note that $\Sigma \Sigma' = 0$ and $(\Sigma')^2 = \Sigma'$.
We define $P = V \Sigma' V^*$ and check the desired properties:


*

*$HP = U \Sigma V^* V \Sigma' V^* = U \Sigma \Sigma' V^* = U 0 V^* = 0$,

*$P^2 = V \Sigma' V^* V \Sigma' V^* = V \Sigma' \Sigma' V^* = V (\Sigma')^2 V^* = V \Sigma' V^* = P$.


Also, if $P$ had a higher rank, than $\Sigma \Sigma' \ne 0$, so $P$ is the desired projection.
Of course, if you're doing this in Matlab (or anything else on a computer), be careful what you treat as a zero.
