# How to minimize a function of single integer variable?

**URL:** <https://discourse.julialang.org/t/how-to-minimize-a-function-of-single-integer-variable/34115>\
**Category:** Optimization (Mathematical)\
**Created:** [February 3, 2020, 1:46pm UTC](https://discourse.julialang.org/t/how-to-minimize-a-function-of-single-integer-variable/34115 "2020-02-03T13:46:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gregstrq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregstrq/32/20620_2.png) [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Post date:** [February 3, 2020, 1:46pm UTC](https://discourse.julialang.org/t/how-to-minimize-a-function-of-single-integer-variable/34115/1 "2020-02-03T13:46:52Z")

</div>

Let’s suppose I have a function f(m): \mathbb{N}\rightarrow\mathbb{R}.  
What method should I use to minimize it?

The function is supposed to be smooth if we continue it from \mathbb{N} to [1,+\infty).  
Also, it’s continuation is either monotonically increasing (minimum for m=1) or has a single local minima which is also the global one (minimum is somewhere in (1,+\infty)).

May be I should adapt some derivative free method to integer input variables?  
If it is indeed the right way to go, can anyone suggest a derivative free method which is particularly good for functions of **single** variable?

Thank you.

---

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [February 3, 2020, 3:34pm UTC](https://discourse.julialang.org/t/how-to-minimize-a-function-of-single-integer-variable/34115/2 "2020-02-03T15:34:30Z")

</div>

If we are talking about methods:  
A bisection method with a lot of initial points it’s the most robust method I can think of, and it can be adapted to integer search (simply use div instead of /)  
Also, if it’s fron N-\>R, why not generalize the function to R - \>R and use Newton?

---

<div class="post-metadata">

**Author:** ![Gregstrq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gregstrq/32/20620_2.png) [@Gregstrq](https://discourse.julialang.org/u/Gregstrq)\
**Post date:** [February 3, 2020, 4:08pm UTC](https://discourse.julialang.org/t/how-to-minimize-a-function-of-single-integer-variable/34115/3 "2020-02-03T16:08:22Z")

</div>

> [@longemen3000](#):
>
> Also, if it’s fron N-\>R, why not generalize the function to R - \>R and use Newton?

My assumption about smoothness is only an assumption: there seems to be no reason to expect that some bad singularities happen. At the same time I can not construct this continuation explicitly.

> [@longemen3000](#):
>
> A bisection method with a lot of initial points it’s the most robust method I can think of

Bisection method is good for finding zeroes of a function. I did some googling after the initial post and it seems that a good approach is to use Fibonacci search in my case.  
Nevertheless, thank you for your help.
