Given $A \in \mathbb R^{n\times n}$, I was told that
$$\mbox{dist}(A, \mbox{SO}(n)) = \inf_{Q \in \mbox{SO}(n)} |A-Q| \overset ? = \inf_{Q \in \mbox{SO}(n)} | Q^\top A - \text{Id} |$$
where we use the Frobenius norm
$$|A| := \sqrt{\text{tr}(A^\top A)}$$
I do not see why that equality holds. Clearly, $\mbox{SO}(n)=\{Q^\top P\,|\, P\in SO(n)\}$, but I do not see how this is helping, as the distance ranges over all $Q \in \mbox{SO}(n)$. Any help would be very much appreciated!
Since $\mathrm Q \mathrm Q^\top = \mathrm Q^\top \mathrm Q = \mathrm I_n$,
$$\begin{aligned} \| \mathrm A - \mathrm Q \|_{\text{F}}^2 &= \| \mathrm Q \mathrm Q^\top \mathrm A - \mathrm Q \|_{\text{F}}^2\\ &= \| \mathrm Q \left( \mathrm Q^\top \mathrm A - \mathrm I_n \right) \|_{\text{F}}^2\\ &= \mbox{tr} \left( \left( \mathrm Q^\top \mathrm A - \mathrm I_n \right)^\top \mathrm Q^\top \mathrm Q \left( \mathrm Q^\top \mathrm A - \mathrm I_n \right) \right)\\ &= \mbox{tr} \left( \left( \mathrm Q^\top \mathrm A - \mathrm I_n \right)^\top \left( \mathrm Q^\top \mathrm A - \mathrm I_n \right) \right)\\ &= \| \mathrm Q^\top \mathrm A - \mathrm I_n \|_{\text{F}}^2\end{aligned}$$