# Numerical Minimization

**URL:** <https://root-forum.cern.ch/t/numerical-minimization/58770>\
**Category:** Evolution Proposals, Apps & Ideas\
**Created:** [March 29, 2024, 12:25am UTC](https://root-forum.cern.ch/t/numerical-minimization/58770 "2024-03-29T00:25:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrea\_Capra](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/andrea_capra/32/24027_2.png) [@Andrea\_Capra](https://root-forum.cern.ch/u/Andrea_Capra)\
**Post date:** [March 29, 2024, 12:25am UTC](https://root-forum.cern.ch/t/numerical-minimization/58770/1 "2024-03-29T00:25:03Z")

</div>

[LineNumericalMinimization.C](https://root-forum.cern.ch/uploads/short-url/hFapDvXM8xZ8G0NAGSZf66w5BhD.C) (6.7 KB)

The `ROOT::Math::Functor` class reference doesn’t give precise indication of how to use it with the abstract minimizer class `ROOT::Math::Minimizer`.

In the attached code, I show how to use it `Functor` for different versions of ROOT.

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [March 29, 2024, 1:04am UTC](https://root-forum.cern.ch/t/numerical-minimization/58770/2 "2024-03-29T01:04:36Z")

</div>

Hi @Andrea_Capra,

thanks for sharing!

I see that your example builds on top of an existing tutorial:  
[https://root.cern/doc/master/NumericalMinimization\_8C.html](https://root.cern/doc/master/NumericalMinimization_8C.html)

One difference is that you use a member function as the evaluation function in the functor.

In my opinion, using a lambda would be a bit more idiomic in modern C++ compared to the `std::mem_fn`:

```auto
    ROOT::Math::Functor f([&](double const * x){ return line.Eval(x); }, 2);

```

By the way, are you posting this here because you are suggesting updates to the ROOT tutorials and documentation?

Cheers,  
Jonas

---

<div class="post-metadata">

**Author:** ![Andrea\_Capra](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/andrea_capra/32/24027_2.png) [@Andrea\_Capra](https://root-forum.cern.ch/u/Andrea_Capra)\
**Post date:** [March 29, 2024, 1:27am UTC](https://root-forum.cern.ch/t/numerical-minimization/58770/3 "2024-03-29T01:27:38Z")

</div>

Hi @jonas ,

the goal of this example is to understand what this meant

 ![screenshot](https://root-forum.cern.ch/uploads/default/original/3X/5/0/5033dc42dd281d58bde503cad9046c0b3cb5c4b0.png)  
from [ROOT: ROOT::Math::Functor Class Reference](https://root.cern.ch/doc/master/classROOT_1_1Math_1_1Functor.html)  
Also I needed to understand the difference between ROOT versions, which causes troubles here.

Finally, I apologize if this is was not right place to post this.  
Since this is not a question, but a potential “solution” to someone else problem.

Best,  
Andrea
