# Help interpreting an error with exponentials using JuMP variables

**URL:** <https://discourse.julialang.org/t/help-interpreting-an-error-with-exponentials-using-jump-variables/11489>\
**Category:** New to Julia\
**Tags:** question, optimization\
**Created:** [June 6, 2018, 10:25pm UTC](https://discourse.julialang.org/t/help-interpreting-an-error-with-exponentials-using-jump-variables/11489 "2018-06-06T22:25:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CPPhysics](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cpphysics/32/4372_2.png) [@CPPhysics](https://discourse.julialang.org/u/CPPhysics)\
**Post date:** [June 6, 2018, 10:25pm UTC](https://discourse.julialang.org/t/help-interpreting-an-error-with-exponentials-using-jump-variables/11489/1 "2018-06-06T22:25:00Z")

</div>

Any help would be appreciated with this problem:

```julia
using NLopt
using JuMP

m=Model(solver=NLoptSolver(algorithm=:DIRECT))

R_=diagm([R0,R1])
R=flipdim(R_,2)
Q=diagm([Q0,Q1])

T=kron(Q,Diagonal(ones(2)))+kron(Diagonal(ones(2)),conj(Q))+kron(R,conj(R))

@variable(m,R0)
@variable(m,R1)
@variable(m,Q0)
@variable(m,Q1)

W=e^(T)

@NLobjective(m,Min,W)

status=solve(m)

```

Error:

```julia
MethodError: no method matching ^(::Irrational{:e}, ::Array{JuMP.GenericQuadExpr{Float64,JuMP.Variable},2})
Closest candidates are:
  ^(::Irrational{:e}, ::Irrational) at irrationals.jl:219
  ^(::Irrational{:e}, ::Rational) at irrationals.jl:219
  ^(::Irrational{:e}, ::Integer) at irrationals.jl:219

```

I have omitted some details and shortened functions for privacy but I could include more if necessary.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [June 8, 2018, 1:36pm UTC](https://discourse.julialang.org/t/help-interpreting-an-error-with-exponentials-using-jump-variables/11489/2 "2018-06-08T13:36:30Z")

</div>

Does it help to use `exp(T) `?

---

<div class="post-metadata">

**Author:** ![CPPhysics](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cpphysics/32/4372_2.png) [@CPPhysics](https://discourse.julialang.org/u/CPPhysics)\
**Post date:** [June 8, 2018, 2:07pm UTC](https://discourse.julialang.org/t/help-interpreting-an-error-with-exponentials-using-jump-variables/11489/3 "2018-06-08T14:07:00Z")

</div>

Unfortunately it doesn’t, it seems julia doesn’t want to take the exponential of my JuMP array, is that a usual problem? I will try to fix other parts of my code and come back to this. Thank you.

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [June 8, 2018, 2:22pm UTC](https://discourse.julialang.org/t/help-interpreting-an-error-with-exponentials-using-jump-variables/11489/4 "2018-06-08T14:22:19Z")

</div>

Your code seems to be out of order (the `@variable` statements should come before `R`, `Q` and `T`).

What are you trying to do? `T` is a 4x4 matrix. Its exponential (be it elementwise or a matrix exponential) is a 4x4 matrix, so how can that be the objective of an optimization?

---

<div class="post-metadata">

**Author:** ![CPPhysics](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cpphysics/32/4372_2.png) [@CPPhysics](https://discourse.julialang.org/u/CPPhysics)\
**Post date:** [June 8, 2018, 2:47pm UTC](https://discourse.julialang.org/t/help-interpreting-an-error-with-exponentials-using-jump-variables/11489/5 "2018-06-08T14:47:51Z")

</div>

Sorry, I just didn’t include the full expression of the objective to try to minimize the code. I have fixed the order of the `@variable` statements. I have another thread where I have posted my updated code with a new problem [help-creating-a-jump-variable-array](https://discourse.julialang.org/t/help-creating-a-jump-variable-array/11515/5) So I won’t repost it here to reduce redundancy, however I can eventually post my full minimization expression if my problems aren’t worked out my other post. Thank you for your help!
