# Encode matrix function which depends on optimization variables at each step

**URL:** <https://discourse.julialang.org/t/encode-matrix-function-which-depends-on-optimization-variables-at-each-step/23831>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [May 3, 2019, 7:44pm UTC](https://discourse.julialang.org/t/encode-matrix-function-which-depends-on-optimization-variables-at-each-step/23831 "2019-05-03T19:44:05Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![jacob-roth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jacob-roth/32/1862_2.png) [@jacob-roth](https://discourse.julialang.org/u/jacob-roth)\
**Post date:** [May 5, 2019, 3:03am UTC](https://discourse.julialang.org/t/encode-matrix-function-which-depends-on-optimization-variables-at-each-step/23831/6 "2019-05-05T03:03:42Z")

</div>

So this means opting for approach (2) and registering a function to compute C(x) := -A^{-1}(x) B and its derivative? Otherwise I only see how to encode a full n^2 constraint Y as

\begin{align} Y = C D C^{\top} \iff A Y A^{\top} = B D B^{\top} \end{align}

Or is there a way to rearrange the computation to enforce only y = {\rm diag}(Y) that I’m missing?

---

_[View the full topic](https://discourse.julialang.org/t/encode-matrix-function-which-depends-on-optimization-variables-at-each-step/23831)._
