# Finding minimum value of function (interval mathematics)

**URL:** <https://community.wolfram.com/t/finding-minimum-value-of-function-interval-mathematics/1923>\
**Category:** Questions\
**Tags:** mathematica, graphics-and-visualization, optimization\
**Created:** [April 7, 2014, 8:56pm UTC](https://community.wolfram.com/t/finding-minimum-value-of-function-interval-mathematics/1923 "2014-04-07T20:56:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vitavictoriya](https://avatars.discourse-cdn.com/v4/letter/v/e19b73/32.png) [@vitavictoriya](https://community.wolfram.com/u/vitavictoriya)\
**Post date:** [April 7, 2014, 8:56pm UTC](https://community.wolfram.com/t/finding-minimum-value-of-function-interval-mathematics/1923/1 "2014-04-07T20:56:31Z")

</div>

Hi! I must find minimum of function as follows.  
For example, I have such a graphic

 ![k1.jpg](https://global.discourse-cdn.com/wolfram/original/2X/3/371f34945053c12ce38b7b05f9b07c9a0840c6eb.jpeg)I saw that there are two points of minimum and some of rectangles are exactly higher than others, so I need discard them and continue only with the remaining rectangles.  
 ![k2.jpg](https://global.discourse-cdn.com/wolfram/original/3X/9/e/9e57b09f87ac51a2ae96cb5f7ae5217dbdef3d43.jpeg)  
If I can’t see exactly which rectangles are higher I must divide my interval on more rectangles.  
Thanks,  
Viktoriya.  
P.S. I know how draw rectangles on a function:

```auto
gr[f_, xmin_, xmax_, slices_] := 
 Module[{span = (xmax - xmin)/slices, ext}, 
  ext[op_, r_] := First@Quiet@op[{f[x], r <= x <= r + span}, x]; 
  Plot[f[x], {x, xmin, xmax}, 
   Prolog -> {FaceForm[Gray], EdgeForm, 
     Rectangle @@@ ({{#, ext[Minimize, #]}, {# + span, 
           ext[Maximize, #]}} & /@ Most@Range[xmin, xmax, span])}]]; 
f[x_] := x + 3*Sin[x + 2]; gr[f, -5, 5, 10]

```

---

<div class="post-metadata">

**Author:** ![sblinder](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sblinder/32/17861_2.png) [@sblinder](https://community.wolfram.com/u/sblinder)\
**Post date:** [April 8, 2014, 3:28pm UTC](https://community.wolfram.com/t/finding-minimum-value-of-function-interval-mathematics/1923/2 "2014-04-08T15:28:50Z")

</div>

You should first find all the stationary points of the function.

```auto
FindRoot[f'[x]==0,x]

```

Then check each x to identify maxima and minima and identify largest maximum. Can use

```auto
Max[x1,x2,...]

```

---

<div class="post-metadata">

**Author:** ![mthiel](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mthiel/32/42877_2.png) [@mthiel](https://community.wolfram.com/u/mthiel)\
**Post date:** [April 8, 2014, 7:01pm UTC](https://community.wolfram.com/t/finding-minimum-value-of-function-interval-mathematics/1923/3 "2014-04-08T19:01:10Z")

</div>

The notation might be a bit confusing. I suppose that x1, x2 etc are the x-coordinates of the extrema. If that is so to determine the global maximum one might want to calculate

```auto
Max[f[x1],f[x2],...] (*This is not Mathematica notation*)

```

Perhaps this is better:

```auto
f[x_] := x + 3*Sin[x + 2];
Solve[D[f[x], x] == 0, x]

```

and then

```auto
f[x] /. {{x -> -2 - ArcCos[-(1/3)]}, {x -> -2 + ArcCos[-(1/3)]}}f[x] /. {{x -> -2 - ArcCos[-(1/3)]}, {x -> -2 + ArcCos[-(1/3)]}}

(*{-2 - 2 Sqrt[2] - ArcCos[-(1/3)], -2 + 2 Sqrt[2] + ArcCos[-(1/3)]}{-2 - 2 Sqrt[2] - ArcCos[-(1/3)], -2 + 2 Sqrt[2] + ArcCos[-(1/3)]}*)

```

But I don’t think that this answers Victoriya’s questions.

M.

---

<div class="post-metadata">

**Author:** ![danl](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/danl/32/41267_2.png) [@danl](https://community.wolfram.com/u/danl)\
**Post date:** [April 8, 2014, 10:59pm UTC](https://community.wolfram.com/t/finding-minimum-value-of-function-interval-mathematics/1923/4 "2014-04-08T22:59:22Z")

</div>

Stan Wagon has written global optimization code that works via intervals. Below are a couple of references.

[http://www-sbras.nsc.ru/interval/Library/Surveys/ThinkGlobally.pdf?PHPSESSID=df71c15e5c2bcf30c47aeb0f975ed2cc](http://www-sbras.nsc.ru/interval/Library/Surveys/ThinkGlobally.pdf?PHPSESSID=df71c15e5c2bcf30c47aeb0f975ed2cc)

[http://www.mathematica-journal.com/issue/v9i3/newpublications/ISBN089871561X.html](http://www.mathematica-journal.com/issue/v9i3/newpublications/ISBN089871561X.html)

---

<div class="post-metadata">

**Author:** ![dlkeith](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dlkeith/32/31494_2.png) [@dlkeith](https://community.wolfram.com/u/dlkeith)\
**Post date:** [April 8, 2014, 11:31pm UTC](https://community.wolfram.com/t/finding-minimum-value-of-function-interval-mathematics/1923/5 "2014-04-08T23:31:53Z")

</div>

I have found that NMinimize and NMaximize are reasonably good at finding the global extremum if the method used is “SimulatedAnnealing” or “RandomSearch” but not so good with the default method.

```auto
In[20]:= f = (x - 1)^2 + 5 Sin[x];

In[21]:= NMinimize[f, x, Method -> "SimulatedAnnealing"]

Out[21]= {-0.348, {x -> -0.779015}}

```
