Solution (source code)

= Solution

Put $B=A_1^TA_1$. It is a <symmetric matrix> and a <positive semidefinite matrix>, while $A_2^TA_2=I_n-B$ is also a <positive semidefinite matrix>. By the <spectral theorem>, choose an <orthogonal matrix> $V=[v_1,\ldots,v_n]$ such that
$$
V^TBV=\operatorname{diag}(\lambda_1,\ldots,\lambda_n),\qquad 0\leq\lambda_j\leq1.
$$
The bounds follow directly from $z^TBz=\|A_1z\|_2^2\in[0,\|z\|_2^2]$. Define the <diagonal matrices>
$$
\Sigma_1=\operatorname{diag}(\sqrt{\lambda_1},\ldots,\sqrt{\lambda_n}),\qquad
\Sigma_2=\operatorname{diag}(\sqrt{1-\lambda_1},\ldots,\sqrt{1-\lambda_n}).
$$
The columns of $A_1V$ are mutually <orthogonal>, since $(A_1v_i)^T(A_1v_j)=\lambda_j\delta_{ij}$. For each $\lambda_j>0$, set $u_{1j}=A_1v_j/\sqrt{\lambda_j}$. These columns are <orthonormal>. At a zero $\lambda_j$, one has $A_1v_j=0$; choose $u_{1j}$ by completing the already prescribed columns to an <orthonormal set> of $n$ columns in $\mathbb R^k$. Such a completion exists because $k\geq n$. This gives $A_1V=U_1\Sigma_1$, including the zero columns.

Likewise, the <Gram matrix> of $A_2V$ is $\operatorname{diag}(1-\lambda_j)$. Normalize its nonzero columns and complete at its zero columns in $\mathbb R^{m-k}$, using $m-k\geq n$. The resulting $U_2$ has <orthonormal> columns and $A_2V=U_2\Sigma_2$. Combining the identities gives
$$
\boxed{A=\begin{pmatrix}U_1&0\\0&U_2\end{pmatrix}
\begin{pmatrix}\Sigma_1\\\Sigma_2\end{pmatrix}V^T}.
$$
This is a form of the <cosine-sine decomposition>. Completing the zero columns is essential: neither block was assumed to have <full column rank>.