# JuMP User-Defined Function, Value and Gradient At Once

**URL:** <https://discourse.julialang.org/t/jump-user-defined-function-value-and-gradient-at-once/8681>\
**Category:** Optimization (Mathematical)\
**Created:** [January 29, 2018, 11:59pm UTC](https://discourse.julialang.org/t/jump-user-defined-function-value-and-gradient-at-once/8681 "2018-01-29T23:59:56Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![miles.lubin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miles.lubin/32/279_2.png) [@miles.lubin](https://discourse.julialang.org/u/miles.lubin)\
**Post date:** [January 30, 2018, 2:25am UTC](https://discourse.julialang.org/t/jump-user-defined-function-value-and-gradient-at-once/8681/2 "2018-01-30T02:25:27Z")

</div>

You can cache the evaluation point and last value/gradient. If the evaluation point doesn’t change, return the value that you’ve already computed. It sounds like your function has a nontrivial evaluation cost; in this case the extra time spent in this check should be negligible.

---

_[View the full topic](https://discourse.julialang.org/t/jump-user-defined-function-value-and-gradient-at-once/8681)._
