1

The documentation for the brent_find_minima function is at https://www.boost.org/doc/libs/1_76_0/libs/math/doc/html/math_toolkit/brent_minima.html

template <class F, class T>
std::pair<T, T> brent_find_minima(F f, T min, T max, int bits);

template <class F, class T>
std::pair<T, T> brent_find_minima(F f, T min, T max, int bits, boost::uintmax_t& max_iter);

However I'm a bit confused on how to convert bits to a tolerance. For example I have some objective function that measures distance

double distance(double x);

which measures some value distance as paramaterized by x. I would like to be able to say that I want the solver to return me the minimum of this function to an accuracy of 0.1 which represents the accuracy I care about.

How do I convert 0.1 to bits?

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065
bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217

1 Answers1

1

I'm not an expert at this, but looking over the source code for Boost's Brent minimization algorithm, it looks like the bit count is used to determine a stopping condition that's based on the magnitude of the current guess. Specifically, the stopping condition is determined from the current guess x and the size of the current window containing the minimum:

|x - current-range-midpoint| ≤ 2ε|x| + ε/2 - (current-range-size) / 2

Here, ε is a small number derived from the number of bits (specifically, it's 21 - bits). Notice that, in particular, if |x| gets larger, then ε needs to get increasingly small for the bound on the left-hand side not to be a large number as the size of the current range decreases.

I will have to confess that I haven't worked out the full math here, but based on this it looks like the number of bits you're going to need is going to be the number of bits to write out the integer part of the answer, plus enough extra bits to get a value that's within 0.1 of the total. The number of bits to write out the integer part of the answer is log2 n, and the number of bits to get to within 0.1 of the total is 4 (1 / 24 = 0.06), so my best guess is that you'll need log2 n + 4 bits if the correct answer is n. To estimate n, look at the two endpoints of the range and take whichever has the larger absolute value.

If this is incorrect, please let me know and I'll remove this answer.

templatetypedef
  • 362,284
  • 104
  • 897
  • 1,065