# Optim.jl : first-order (and second-order) optimization without providing an objective function

**URL:** <https://discourse.julialang.org/t/optim-jl-first-order-and-second-order-optimization-without-providing-an-objective-function/80677>\
**Category:** Optimization (Mathematical)\
**Tags:** optim\
**Created:** [May 7, 2022, 6:21pm UTC](https://discourse.julialang.org/t/optim-jl-first-order-and-second-order-optimization-without-providing-an-objective-function/80677 "2022-05-07T18:21:48Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)\
**Post date:** [May 9, 2022, 6:24am UTC](https://discourse.julialang.org/t/optim-jl-first-order-and-second-order-optimization-without-providing-an-objective-function/80677/14 "2022-05-09T06:24:53Z")

</div>

I asked a similar question here: [How can I use Optim/BFGS on functions I can't evaluate but whose gradients I can compute? - #11 by marius311](https://discourse.julialang.org/t/how-can-i-use-optim-bfgs-on-functions-i-cant-evaluate-but-whose-gradients-i-can-compute/35160/11)

In the end I settled on using a zero-finder on the gradient, specifically Broyden.

One caveat to note is that a zero-finder doesn’t assume the gradient vector is a conservative vector field, even though you secretly know that it is since its a gradient. This generally means these algorithms won’t be exactly equivalent to a hypothetical optimizer that ignores the objective. That said this might just be an academic point, at least on my problems I didn’t find a big difference in practice.

I do wish there was an easy way to have Optim use a fixed step size and to never try and evaluate the object. It seems that LineSearches.Static exists for fixed step size, but I don’t think Optim has an option to never use the objective, at least last time I checked. It would be nice to have that.

---

_[View the full topic](https://discourse.julialang.org/t/optim-jl-first-order-and-second-order-optimization-without-providing-an-objective-function/80677)._
