# How to implment \`logsumexp\` function in JuMP?

**URL:** <https://discourse.julialang.org/t/how-to-implment-logsumexp-function-in-jump/84376>\
**Category:** Optimization (Mathematical)\
**Tags:** jump, differentiation, autodiff\
**Created:** [July 18, 2022, 4:35am UTC](https://discourse.julialang.org/t/how-to-implment-logsumexp-function-in-jump/84376 "2022-07-18T04:35:27Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [July 18, 2022, 5:02am UTC](https://discourse.julialang.org/t/how-to-implment-logsumexp-function-in-jump/84376/2 "2022-07-18T05:02:07Z")

</div>

You typically can’t use arbitrary nonlinear function in JuMP without registering them as user-defined functions: [Nonlinear Modeling · JuMP](https://jump.dev/JuMP.jl/stable/manual/nlp/#User-defined-Functions).

Do you have a reproducible example of what you’re trying to achieve?

The Mosek modeling cookbook [5 Exponential cone optimization — MOSEK Modeling Cookbook 3.3.0](https://docs.mosek.com/modeling-cookbook/expo.html#log-sum-exp) has a conic formulation of logsumexp:

```julia
N = 10
model = Model()
@variable(model, x[1:N])
@NLobjective(model, Min, log(sum(exp(x[i]) for i in 1:N)))
# becomes
model = Model()
@variable(model, x[1:N])
@variable(model, u[1:N])
@variable(model, t)
@constraint(model, sum(u) <= 1)
@constraint(model, [i=1:N], [x[i] - t, 1, u[i]] in MOI.ExponentialCone())
@objective(model, Min, t)

```

---

_[View the full topic](https://discourse.julialang.org/t/how-to-implment-logsumexp-function-in-jump/84376)._
