Given a 3 by 3 matrix $M$ I would like to find the rotation matrix $R$ minimizing the Frobenius norm:

\begin{equation} \|R-M\|_F \end{equation}

Is there a closed form solution for $R$, or is it possible to express $R$ as the solution to a linear system? I would like to avoid gradient descent if possible.


1 Answer 1


Let $M=U\Sigma V$ be the singular value decomposition of $M$, then $R=UV$. If you want $R$ to be a proper rotation (i.e. $\det R=1$) and $UV$ is not, replace the singular vector $\mathbf{u}_3$ associated with the smallest singular value of $M$ with $-\mathbf{u}_3$ in the $U$ matrix. An appropriate reference for this answer is:

N. J. Higham. Matrix nearness problems and applications. In M. J. C. Gover and S. Barnett, editors, Applications of Matrix Theory, pages 1–27. Oxford University Press, 1989.

  • $\begingroup$ What if the distance measure is operator norm? Thank you! $\endgroup$
    – Wuchen
    Sep 7, 2017 at 20:05
  • $\begingroup$ @Wuchen The same is true for the L-2 operator norm. Simply note that multiplying on the left by $U^{-1}$ and on the right by $V^{-1}$ leaves the problem (distances and constraints) invariant. Therefore, the problem is reduced to the case of diagonal matrices, which is straightforward. $\endgroup$ Sep 16, 2017 at 20:22
  • $\begingroup$ @YoavKallus I don't find the case of diagonal matrices straightforward. It's true that replacing $\Sigma$ with $I$ is a feasible solution, but it is not that clear that it is the optimal one. $\endgroup$ Nov 18, 2019 at 12:43
  • $\begingroup$ @FedericoPoloni Since the identity is the nearest matrix with normalized rows to any nonnegative diagonal matrix and also happens to be orthogonal, it is also the nearest orthogonal matrix. $\endgroup$ Nov 18, 2019 at 14:01
  • 1
    $\begingroup$ @FedericoPoloni Ah, sorry I misunderstood your question. The op norm distance to any other row-normalized matrix Q from S is at least the L-2 distance of the row of S containing the sv farthest from 1 to the corresponding row in Q. Therefore, it cannot be smaller than when Q is I (but can be equally small). See Kahan's note linked in the recent question on the unitary version (people.eecs.berkeley.edu/~wkahan/Math128/NearestQ.pdf). $\endgroup$ Nov 18, 2019 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.