Why is the norm the last $m - n$ elements of $Q^Tb$ in least squares?

37 Views Asked by At

The answer to this question says that

If you're solving the Least Squares problem minimizing $||Ax - b||_2$ then the error, or residual, is the norm of the last m-n elements of the vector $Q^Tb$.

where $Q$ is from the $QR$ decomposition. Why is this the case? I attempted this in NumPy and was unable to verify this result.