# Trouble Accessing Minimizer from Optim

**URL:** <https://discourse.julialang.org/t/trouble-accessing-minimizer-from-optim/75763>\
**Category:** New to Julia\
**Tags:** optim\
**Created:** [February 3, 2022, 9:21pm UTC](https://discourse.julialang.org/t/trouble-accessing-minimizer-from-optim/75763 "2022-02-03T21:21:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![as2022](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@as2022](https://discourse.julialang.org/u/as2022)\
**Post date:** [February 3, 2022, 9:21pm UTC](https://discourse.julialang.org/t/trouble-accessing-minimizer-from-optim/75763/1 "2022-02-03T21:21:08Z")

</div>

Hi All,

I am new to Julia and I am using the Optim package for the first time. The optimize function seems to be finding a solution to my problem, but I cannot figure out how to access the solution. All I see is the objective value. The Optim documentation states that the result object should have a “minimizer” field, but whenever I try to access this field, I get an error that “minimizer is not defined”. Any help would be greatly appreciated. I am guessing there is a very simple answer, but I have not been able to figure it out. Thanks!

- Status: success

- Candidate solution  
Final objective value: -1.647806e+00

- Found with  
Algorithm: Fminbox with L-BFGS

- Convergence measures  
|x - x’| = 9.51e-07 ≰ 0.0e+00  
|x - x’|/|x’| = 3.03e-06 ≰ 0.0e+00  
|f(x) - f(x’)| = 0.00e+00 ≤ 0.0e+00  
|f(x) - f(x’)|/|f(x’)| = 0.00e+00 ≤ 0.0e+00  
|g(x)| = 8.43e-10 ≤ 1.0e-08

- Work counters  
Seconds run: 0 (vs limit Inf)  
Iterations: 3  
f(x) calls: 23  
∇f(x) calls: 23

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [February 3, 2022, 9:25pm UTC](https://discourse.julialang.org/t/trouble-accessing-minimizer-from-optim/75763/2 "2022-02-03T21:25:21Z")

</div>

Can you show what you have actually done to get the error? Because this works:

```julia
julia> using Optim

julia> rosenbrock(x) = (1.0 - x[1])^2 + 100.0 * (x[2] - x[1]^2)^2
rosenbrock (generic function with 1 method)

julia> result = optimize(rosenbrock, zeros(2), BFGS())
 * Status: success
(...)

julia> result.minimizer
2-element Vector{Float64}:
 0.9999999926033423
 0.9999999852005353

```

---

<div class="post-metadata">

**Author:** ![as2022](https://avatars.discourse-cdn.com/v4/letter/a/76d3ee/32.png) [@as2022](https://discourse.julialang.org/u/as2022)\
**Post date:** [February 3, 2022, 9:37pm UTC](https://discourse.julialang.org/t/trouble-accessing-minimizer-from-optim/75763/3 "2022-02-03T21:37:28Z")

</div>

Hi, it is working now. I am not sure what I was doing wrong before. Thanks!
