# Solving optimization problems involving orthogonal matrices

**URL:** https://discourse.julialang.org/t/solving-optimization-problems-involving-orthogonal-matrices/135431
**Category:** Optimization (Mathematical)
**Created:** [February 3, 2026, 4:31pm UTC](https://discourse.julialang.org/t/solving-optimization-problems-involving-orthogonal-matrices/135431 "2026-02-03T16:31:59Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [February 3, 2026, 7:13pm UTC](https://discourse.julialang.org/t/solving-optimization-problems-involving-orthogonal-matrices/135431/5 "2026-02-03T19:13:20Z")

</div>

> [@HMegh](#):
>
> I have not tried the second approach yet, but it is a nice trick to keep in mind for the future. However, should I be worried about the condition number of `X'*X`?

No. As long as you start out with a well-conditioned X, it should stay that way. (For example, if your starting X is orthogonal.)

The basic reason for this is similar to [optimizing on a sphere](https://discourse.julialang.org/t/optimization-on-unit-sphere/130720/3) by changing variables to x/\Vert x \Vert: because \nabla\_x f(x/\Vert x \Vert) is tangent to the sphere, gradient-based optimization should never make x stray very far towards the origin. In the same way, the gradient of g(X) = f(X(X^T X)^{-1/2}) is tangent to the manifold of orthogonal matrices, so optimization steps will keep X pretty close to that manifold (i.e., well-conditioned).

(In particular, you can easily show that if X^T X = I, then X^T \nabla g is anti-symmetric. It follows that if you take a small gradient step \delta X = \epsilon \nabla g, then the change in X^T X is O(\epsilon^2), i.e. it stays orthogonal to first order.)

---

_[View the full topic](https://discourse.julialang.org/t/solving-optimization-problems-involving-orthogonal-matrices/135431)._
