# Optimization on Stiefel manifold with auto-differentiation

**URL:** https://discourse.julialang.org/t/optimization-on-stiefel-manifold-with-auto-differentiation/132072
**Category:** Optimization (Mathematical)
**Tags:** question, package
**Created:** [September 3, 2025, 11:30am UTC](https://discourse.julialang.org/t/optimization-on-stiefel-manifold-with-auto-differentiation/132072 "2025-09-03T11:30:29Z")
**Posts on this page:** 1
**Showing post:** 3

<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: [September 3, 2025, 3:54pm UTC](https://discourse.julialang.org/t/optimization-on-stiefel-manifold-with-auto-differentiation/132072/3 "2025-09-03T15:54:20Z")

</div>

You could also just optimize f(X) = f(Y (Y^T Y)^{-1/2}) over unconstrained real square matrices Y.

The [polar decomposition](https://en.wikipedia.org/wiki/Polar_decomposition) X = Y (Y^T Y)^{-1/2} automatically satisfies X^T X = I, and the function `Y / sqrt(Hermitian(Y'Y))` should be differentiable with standard AD packages (e.g. ChainRules.jl has a rule for the [symmetric-matrix square root](https://github.com/JuliaDiff/ChainRules.jl/blob/0923b1e7281b8d1418205a8798cc653c5cbd8552/src/rulesets/LinearAlgebra/symmetric.jl#L284-L289)).

(This is a generalization of a simple trick to optimize on the unit sphere: [Optimization on unit sphere? - #3 by stevengj](https://discourse.julialang.org/t/optimization-on-unit-sphere/130720/3)).

---

_[View the full topic](https://discourse.julialang.org/t/optimization-on-stiefel-manifold-with-auto-differentiation/132072)._
