]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/math/example/brent_minimise_example.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / math / example / brent_minimise_example.cpp
1 //! \file
2 //! \brief Brent_minimise_example.cpp
3
4 // Copyright Paul A. Bristow 2015.
5
6 // Use, modification and distribution are subject to the
7 // Boost Software License, Version 1.0.
8 // (See accompanying file LICENSE_1_0.txt
9 // or copy at http://www.boost.org/LICENSE_1_0.txt)
10
11 // Note that this file contains Quickbook mark-up as well as code
12 // and comments, don't change any of the special comment mark-ups!
13
14 // For some diagnostic information:
15 //#define BOOST_MATH_INSTRUMENT
16 // If quadmath float128 is available:
17 //#define BOOST_HAVE_QUADMATH
18
19 // Example of finding minimum of a function with Brent's method.
20 //[brent_minimise_include_1
21 #include <boost/math/tools/minima.hpp>
22 //] [/brent_minimise_include_1]
23
24 #include <boost/math/special_functions/next.hpp>
25 #include <boost/multiprecision/cpp_dec_float.hpp>
26 #include <boost/math/special_functions/pow.hpp>
27 #include <boost/math/constants/constants.hpp>
28 #include <boost/test/floating_point_comparison.hpp> // For is_close_to and is_small
29
30 //[brent_minimise_mp_include_0
31 #include <boost/multiprecision/cpp_dec_float.hpp> // For decimal boost::multiprecision::cpp_dec_float_50.
32 #include <boost/multiprecision/cpp_bin_float.hpp> // For binary boost::multiprecision::cpp_bin_float_50;
33 //] [/brent_minimise_mp_include_0]
34
35 //#ifndef _MSC_VER // float128 is not yet supported by Microsoft compiler at 2013.
36 #ifdef BOOST_HAVE_QUADMATH // Define only if GCC or Intel, and have quadmath.lib or .dll library available.
37 # include <boost/multiprecision/float128.hpp>
38 #endif
39
40 #include <iostream>
41 // using std::cout; using std::endl;
42 #include <iomanip>
43 // using std::setw; using std::setprecision;
44 #include <limits>
45 using std::numeric_limits;
46 #include <tuple>
47 #include <utility> // pair, make_pair
48 #include <type_traits>
49 #include <typeinfo>
50
51 //typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<50>,
52 // boost::multiprecision::et_off>
53 // cpp_dec_float_50_et_off;
54 //
55 // typedef boost::multiprecision::number<boost::multiprecision::cpp_bin_float<50>,
56 // boost::multiprecision::et_off>
57 // cpp_bin_float_50_et_off;
58
59 // http://en.wikipedia.org/wiki/Brent%27s_method Brent's method
60
61 double f(double x)
62 {
63 return (x + 3) * (x - 1) * (x - 1);
64 }
65
66 //[brent_minimise_double_functor
67 struct funcdouble
68 {
69 double operator()(double const& x)
70 { //
71 return (x + 3) * (x - 1) * (x - 1); // (x + 3)(x - 1)^2
72 }
73 };
74 //] [/brent_minimise_double_functor]
75
76 //[brent_minimise_T_functor
77 struct func
78 {
79 template <class T>
80 T operator()(T const& x)
81 { //
82 return (x + 3) * (x - 1) * (x - 1); //
83 }
84 };
85 //] [/brent_minimise_T_functor]
86
87 //[brent_minimise_close
88 //
89 template <class T = double>
90 bool close(T expect, T got, T tolerance)
91 {
92 using boost::math::fpc::is_close_to;
93 using boost::math::fpc::is_small;
94
95 if (is_small<T>(expect, tolerance))
96 {
97 return is_small<T>(got, tolerance);
98 }
99 else
100 {
101 return is_close_to<T>(expect, got, tolerance);
102 }
103 }
104
105 //] [/brent_minimise_close]
106
107 //[brent_minimise_T_show
108
109 template <class T>
110 void show_minima()
111 {
112 using boost::math::tools::brent_find_minima;
113 try
114 { // Always use try'n'catch blocks with Boost.Math to get any error messages.
115
116 int bits = std::numeric_limits<T>::digits/2; // Maximum is digits/2;
117 std::streamsize prec = static_cast<int>(2 + sqrt(bits)); // Number of significant decimal digits.
118 std::streamsize precision = std::cout.precision(prec); // Save.
119
120 std::cout << "\n\nFor type " << typeid(T).name()
121 << ",\n epsilon = " << std::numeric_limits<T>::epsilon()
122 // << ", precision of " << bits << " bits"
123 << ",\n the maximum theoretical precision from Brent minimization is " << sqrt(std::numeric_limits<T>::epsilon())
124 << "\n Displaying to std::numeric_limits<T>::digits10 " << prec << " significant decimal digits."
125 << std::endl;
126
127 const boost::uintmax_t maxit = 20;
128 boost::uintmax_t it = maxit;
129 // Construct using string, not double, avoids loss of precision.
130 //T bracket_min = static_cast<T>("-4");
131 //T bracket_max = static_cast<T>("1.3333333333333333333333333333333333333333333333333");
132
133 // Construction from double may cause loss of precision for multiprecision types like cpp_bin_float.
134 // but brackets values are good enough for using Brent minimization.
135 T bracket_min = static_cast<T>(-4);
136 T bracket_max = static_cast<T>(1.3333333333333333333333333333333333333333333333333);
137
138 std::pair<T, T> r = brent_find_minima<func, T>(func(), bracket_min, bracket_max, bits, it);
139
140 std::cout << " x at minimum = " << r.first << ", f(" << r.first << ") = " << r.second;
141 if (it < maxit)
142 {
143 std::cout << ",\n met " << bits << " bits precision" << ", after " << it << " iterations." << std::endl;
144 }
145 else
146 {
147 std::cout << ",\n did NOT meet " << bits << " bits precision" << " after " << it << " iterations!" << std::endl;
148 }
149 // Check that result is that expected (compared to theoretical uncertainty).
150 T uncertainty = sqrt(std::numeric_limits<T>::epsilon());
151 //std::cout << std::boolalpha << "x == 1 (compared to uncertainty " << uncertainty << ") is " << close(static_cast<T>(1), r.first, uncertainty) << std::endl;
152 //std::cout << std::boolalpha << "f(x) == (0 compared to uncertainty " << uncertainty << ") is " << close(static_cast<T>(0), r.second, uncertainty) << std::endl;
153 // Problems with this using multiprecision with expression template on?
154 std::cout.precision(precision); // Restore.
155 }
156 catch (const std::exception& e)
157 { // Always useful to include try & catch blocks because default policies
158 // are to throw exceptions on arguments that cause errors like underflow, overflow.
159 // Lacking try & catch blocks, the program will abort without a message below,
160 // which may give some helpful clues as to the cause of the exception.
161 std::cout <<
162 "\n""Message from thrown exception was:\n " << e.what() << std::endl;
163 }
164 } // void show_minima()
165
166 //] [/brent_minimise_T_show]
167
168 int main()
169 {
170 std::cout << "Brent's minimisation example." << std::endl;
171 std::cout << std::boolalpha << std::endl;
172
173 // Tip - using
174 // std::cout.precision(std::numeric_limits<T>::digits10);
175 // during debugging is wise because it shows if construction of multiprecision involves conversion from double
176 // by finding random or zero digits after 17.
177
178 // Specific type double - unlimited iterations.
179 using boost::math::tools::brent_find_minima;
180
181 //[brent_minimise_double_1
182 int bits = std::numeric_limits<double>::digits;
183
184 std::pair<double, double> r = brent_find_minima(funcdouble(), -4., 4. / 3, bits);
185
186 std::cout.precision(std::numeric_limits<double>::digits10);
187 std::cout << "x at minimum = " << r.first << ", f(" << r.first << ") = " << r.second << std::endl;
188 // x at minimum = 1.00000000112345, f(1.00000000112345) = 5.04852568272458e-018
189 //] [/brent_minimise_double_1]
190
191 std::cout << "x at minimum = " << (r.first - 1.) /r.first << std::endl;
192
193 double uncertainty = sqrt(std::numeric_limits<double>::epsilon());
194 std::cout << "Uncertainty sqrt(epsilon) = " << uncertainty << std::endl;
195 // sqrt(epsilon) = 1.49011611938477e-008
196 // (epsilon is always > 0, so no need to take abs value).
197
198 using boost::math::fpc::is_close_to;
199 using boost::math::fpc::is_small;
200
201 std::cout << is_close_to(1., r.first, uncertainty) << std::endl;
202 std::cout << is_small(r.second, uncertainty) << std::endl;
203
204 std::cout << std::boolalpha << "x == 1 (compared to uncertainty " << uncertainty << ") is " << close(1., r.first, uncertainty) << std::endl;
205 std::cout << std::boolalpha << "f(x) == (0 compared to uncertainty " << uncertainty << ") is " << close(0., r.second, uncertainty) << std::endl;
206
207 // Specific type double - limit maxit to 20 iterations.
208 std::cout << "Precision bits = " << bits << std::endl;
209 //[brent_minimise_double_2
210 const boost::uintmax_t maxit = 20;
211 boost::uintmax_t it = maxit;
212 r = brent_find_minima(funcdouble(), -4., 4. / 3, bits, it);
213 std::cout << "x at minimum = " << r.first << ", f(" << r.first << ") = " << r.second
214 << " after " << it << " iterations. " << std::endl;
215 //] [/brent_minimise_double_2]
216 // x at minimum = 1.00000000112345, f(1.00000000112345) = 5.04852568272458e-018
217
218 //[brent_minimise_double_3
219
220 std::streamsize prec = static_cast<int>(2 + sqrt(bits)); // Number of significant decimal digits.
221 std::cout << "Showing " << bits << " bits precision with " << prec
222 << " decimal digits from tolerance " << sqrt(std::numeric_limits<double>::epsilon())
223 << std::endl;
224 std::streamsize precision = std::cout.precision(prec); // Save.
225
226 std::cout << "x at minimum = " << r.first << ", f(" << r.first << ") = " << r.second
227 << " after " << it << " iterations. " << std::endl;
228
229 //] [/brent_minimise_double_3]
230 // Showing 53 bits precision with 9 decimal digits from tolerance 1.49011611938477e-008
231 // x at minimum = 1, f(1) = 5.04852568e-018
232
233 {
234 //[brent_minimise_double_4
235 bits /= 2; // Half digits precision (effective maximum).
236 double epsilon_2 = boost::math::pow<-(std::numeric_limits<double>::digits/2 - 1), double>(2);
237
238 std::cout << "Showing " << bits << " bits precision with " << prec
239 << " decimal digits from tolerance " << sqrt(epsilon_2)
240 << std::endl;
241 std::streamsize precision = std::cout.precision(prec); // Save.
242
243 boost::uintmax_t it = maxit;
244 r = brent_find_minima(funcdouble(), -4., 4. / 3, bits, it);
245 std::cout << "x at minimum = " << r.first << ", f(" << r.first << ") = " << r.second << std::endl;
246 std::cout << it << " iterations. " << std::endl;
247 //] [/brent_minimise_double_4]
248 }
249 // x at minimum = 1, f(1) = 5.04852568e-018
250
251 {
252 //[brent_minimise_double_5
253 bits /= 2; // Quarter precision.
254 double epsilon_4 = boost::math::pow<-(std::numeric_limits<double>::digits / 4 - 1), double>(2);
255
256 std::cout << "Showing " << bits << " bits precision with " << prec
257 << " decimal digits from tolerance " << sqrt(epsilon_4)
258 << std::endl;
259 std::streamsize precision = std::cout.precision(prec); // Save.
260
261 boost::uintmax_t it = maxit;
262 r = brent_find_minima(funcdouble(), -4., 4. / 3, bits, it);
263 std::cout << "x at minimum = " << r.first << ", f(" << r.first << ") = " << r.second
264 << ", after " << it << " iterations. " << std::endl;
265 //] [/brent_minimise_double_5]
266 }
267
268 // Showing 13 bits precision with 9 decimal digits from tolerance 0.015625
269 // x at minimum = 0.9999776, f(0.9999776) = 2.0069572e-009
270 // 7 iterations.
271
272 {
273 //[brent_minimise_template_1
274 std::cout.precision(std::numeric_limits<long double>::digits10);
275 long double bracket_min = -4.;
276 long double bracket_max = 4. / 3;
277 int bits = std::numeric_limits<long double>::digits;
278 const boost::uintmax_t maxit = 20;
279 boost::uintmax_t it = maxit;
280
281 std::pair<long double, long double> r = brent_find_minima(func(), bracket_min, bracket_max, bits, it);
282 std::cout << "x at minimum = " << r.first << ", f(" << r.first << ") = " << r.second
283 << ", after " << it << " iterations. " << std::endl;
284 //] [/brent_minimise_template_1]
285 }
286
287 // Show use of built-in type Template versions.
288 // (Will not work if construct bracket min and max from string).
289
290 //[brent_minimise_template_fd
291 show_minima<float>();
292 show_minima<double>();
293 show_minima<long double>();
294 //] [/brent_minimise_template_fd]
295
296 using boost::multiprecision::cpp_bin_float_50; // binary.
297
298 //[brent_minimise_mp_include_1
299 #ifdef BOOST_HAVE_QUADMATH // Define only if GCC or Intel and have quadmath.lib or .dll library available.
300 using boost::multiprecision::float128;
301 #endif
302 //] [/brent_minimise_mp_include_1]
303
304 //[brent_minimise_template_quad
305 // #ifndef _MSC_VER
306 #ifdef BOOST_HAVE_QUADMATH // Define only if GCC or Intel and have quadmath.lib or .dll library available.
307 show_minima<float128>(); // Needs quadmath_snprintf, sqrtQ, fabsq that are in in quadmath library.
308 #endif
309 //] [/brent_minimise_template_quad
310
311 // User-defined floating-point template.
312
313 //[brent_minimise_mp_typedefs
314 using boost::multiprecision::cpp_bin_float_50; // binary.
315
316 typedef boost::multiprecision::number<boost::multiprecision::cpp_bin_float<50>,
317 boost::multiprecision::et_on>
318 cpp_bin_float_50_et_on; // et_on is default so is same as cpp_bin_float_50.
319
320 typedef boost::multiprecision::number<boost::multiprecision::cpp_bin_float<50>,
321 boost::multiprecision::et_off>
322 cpp_bin_float_50_et_off;
323
324 using boost::multiprecision::cpp_dec_float_50; // decimal.
325
326 typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<50>,
327 boost::multiprecision::et_on> // et_on is default so is same as cpp_dec_float_50.
328 cpp_dec_float_50_et_on;
329
330 typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<50>,
331 boost::multiprecision::et_off>
332 cpp_dec_float_50_et_off;
333 //] [/brent_minimise_mp_typedefs]
334
335 { // binary ET on by default.
336 //[brent_minimise_mp_1
337 std::cout.precision(std::numeric_limits<cpp_bin_float_50>::digits10);
338
339 cpp_bin_float_50 fpv("-1.2345");
340 cpp_bin_float_50 absv;
341
342 absv = fpv < static_cast<cpp_bin_float_50>(0) ? -fpv : fpv;
343 std::cout << fpv << ' ' << absv << std::endl;
344
345
346 int bits = std::numeric_limits<cpp_bin_float_50>::digits / 2 - 2;
347
348 cpp_bin_float_50 bracket_min = static_cast<cpp_bin_float_50>("-4");
349 cpp_bin_float_50 bracket_max = static_cast<cpp_bin_float_50>("1.3333333333333333333333333333333333333333333333333");
350
351 std::cout << bracket_min << " " << bracket_max << std::endl;
352 const boost::uintmax_t maxit = 20;
353 boost::uintmax_t it = maxit;
354 std::pair<cpp_bin_float_50, cpp_bin_float_50> r = brent_find_minima(func(), bracket_min, bracket_max, bits, it);
355
356 std::cout << "x at minimum = " << r.first << ", f(" << r.first << ") = " << r.second
357 // x at minimum = 1, f(1) = 5.04853e-018
358 << ", after " << it << " iterations. " << std::endl;
359
360 close(static_cast<cpp_bin_float_50>(1), r.first, sqrt(std::numeric_limits<cpp_bin_float_50>::epsilon()));
361
362 //] [/brent_minimise_mp_1]
363
364 /*
365 //[brent_minimise_mp_output_1
366 For type class boost::multiprecision::number<class boost::multiprecision::backends::cpp_bin_float<50, 10, void, int, 0, 0>, 1>,
367 epsilon = 5.3455294202e-51,
368 the maximum theoretical precision from Brent minimization is 7.311312755e-26
369 Displaying to std::numeric_limits<T>::digits10 11 significant decimal digits.
370 x at minimum = 1, f(1) = 5.6273022713e-58,
371 met 84 bits precision, after 14 iterations.
372 //] [/brent_minimise_mp_output_1]
373 */
374 //[brent_minimise_mp_2
375 show_minima<cpp_bin_float_50_et_on>(); //
376 //] [/brent_minimise_mp_2]
377
378 /*
379 //[brent_minimise_mp_output_2
380 For type class boost::multiprecision::number<class boost::multiprecision::backends::cpp_bin_float<50, 10, void, int, 0, 0>, 1>,
381
382 //] [/brent_minimise_mp_output_1]
383 */
384 }
385
386 { // binary ET on explicit
387 std::cout.precision(std::numeric_limits<cpp_bin_float_50_et_on>::digits10);
388
389 int bits = std::numeric_limits<cpp_bin_float_50_et_on>::digits / 2 - 2;
390
391 cpp_bin_float_50_et_on bracket_min = static_cast<cpp_bin_float_50_et_on>("-4");
392 cpp_bin_float_50_et_on bracket_max = static_cast<cpp_bin_float_50_et_on>("1.3333333333333333333333333333333333333333333333333");
393
394 std::cout << bracket_min << " " << bracket_max << std::endl;
395 const boost::uintmax_t maxit = 20;
396 boost::uintmax_t it = maxit;
397 std::pair<cpp_bin_float_50_et_on, cpp_bin_float_50_et_on> r = brent_find_minima(func(), bracket_min, bracket_max, bits, it);
398
399 std::cout << "x at minimum = " << r.first << ", f(" << r.first << ") = " << r.second << std::endl;
400 // x at minimum = 1, f(1) = 5.04853e-018
401 std::cout << it << " iterations. " << std::endl;
402
403 show_minima<cpp_bin_float_50_et_on>(); //
404
405 }
406 return 0;
407
408 { // binary ET off
409 std::cout.precision(std::numeric_limits<cpp_bin_float_50_et_off>::digits10);
410
411 int bits = std::numeric_limits<cpp_bin_float_50_et_off>::digits / 2 - 2;
412 cpp_bin_float_50_et_off bracket_min = static_cast<cpp_bin_float_50_et_off>("-4");
413 cpp_bin_float_50_et_off bracket_max = static_cast<cpp_bin_float_50_et_off>("1.3333333333333333333333333333333333333333333333333");
414
415 std::cout << bracket_min << " " << bracket_max << std::endl;
416 const boost::uintmax_t maxit = 20;
417 boost::uintmax_t it = maxit;
418 std::pair<cpp_bin_float_50_et_off, cpp_bin_float_50_et_off> r = brent_find_minima(func(), bracket_min, bracket_max, bits, it);
419
420 std::cout << "x at minimum = " << r.first << ", f(" << r.first << ") = " << r.second << std::endl;
421 // x at minimum = 1, f(1) = 5.04853e-018
422 std::cout << it << " iterations. " << std::endl;
423
424 show_minima<cpp_bin_float_50_et_off>(); //
425 }
426
427 { // decimal ET on by default
428 std::cout.precision(std::numeric_limits<cpp_dec_float_50>::digits10);
429
430 int bits = std::numeric_limits<cpp_dec_float_50>::digits / 2 - 2;
431
432 cpp_dec_float_50 bracket_min = static_cast<cpp_dec_float_50>("-4");
433 cpp_dec_float_50 bracket_max = static_cast<cpp_dec_float_50>("1.3333333333333333333333333333333333333333333333333");
434
435 std::cout << bracket_min << " " << bracket_max << std::endl;
436 const boost::uintmax_t maxit = 20;
437 boost::uintmax_t it = maxit;
438 std::pair<cpp_dec_float_50, cpp_dec_float_50> r = brent_find_minima(func(), bracket_min, bracket_max, bits, it);
439
440 std::cout << "x at minimum = " << r.first << ", f(" << r.first << ") = " << r.second << std::endl;
441 // x at minimum = 1, f(1) = 5.04853e-018
442 std::cout << it << " iterations. " << std::endl;
443
444 show_minima<cpp_dec_float_50>();
445 }
446
447 { // decimal ET on
448 std::cout.precision(std::numeric_limits<cpp_dec_float_50_et_on>::digits10);
449
450 int bits = std::numeric_limits<cpp_dec_float_50_et_on>::digits / 2 - 2;
451
452 cpp_dec_float_50_et_on bracket_min = static_cast<cpp_dec_float_50_et_on>("-4");
453 cpp_dec_float_50_et_on bracket_max = static_cast<cpp_dec_float_50_et_on>("1.3333333333333333333333333333333333333333333333333");
454 std::cout << bracket_min << " " << bracket_max << std::endl;
455 const boost::uintmax_t maxit = 20;
456 boost::uintmax_t it = maxit;
457 std::pair<cpp_dec_float_50_et_on, cpp_dec_float_50_et_on> r = brent_find_minima(func(), bracket_min, bracket_max, bits, it);
458
459 std::cout << "x at minimum = " << r.first << ", f(" << r.first << ") = " << r.second << std::endl;
460 // x at minimum = 1, f(1) = 5.04853e-018
461 std::cout << it << " iterations. " << std::endl;
462
463 show_minima<cpp_dec_float_50_et_on>();
464
465 }
466
467 { // decimal ET off
468 std::cout.precision(std::numeric_limits<cpp_dec_float_50_et_off>::digits10);
469
470 int bits = std::numeric_limits<cpp_dec_float_50_et_off>::digits / 2 - 2;
471
472 cpp_dec_float_50_et_off bracket_min = static_cast<cpp_dec_float_50_et_off>("-4");
473 cpp_dec_float_50_et_off bracket_max = static_cast<cpp_dec_float_50_et_off>("1.3333333333333333333333333333333333333333333333333");
474
475 std::cout << bracket_min << " " << bracket_max << std::endl;
476 const boost::uintmax_t maxit = 20;
477 boost::uintmax_t it = maxit;
478 std::pair<cpp_dec_float_50_et_off, cpp_dec_float_50_et_off> r = brent_find_minima(func(), bracket_min, bracket_max, bits, it);
479
480 std::cout << "x at minimum = " << r.first << ", f(" << r.first << ") = " << r.second << std::endl;
481 // x at minimum = 1, f(1) = 5.04853e-018
482 std::cout << it << " iterations. " << std::endl;
483
484 show_minima<cpp_dec_float_50_et_off>();
485 }
486
487 return 0;
488 } // int main()
489
490
491 /*
492
493
494
495 // GCC 4.9.1 with quadmath
496
497 Brent's minimisation example.
498 x at minimum = 1.00000000112345, f(1.00000000112345) = 5.04852568272458e-018
499 x at minimum = 1.12344622367552e-009
500 Uncertainty sqrt(epsilon) = 1.49011611938477e-008
501 x == 1 (compared to uncertainty 1.49011611938477e-008) is true
502 f(x) == (0 compared to uncertainty 1.49011611938477e-008) is true
503 Precision bits = 53
504 x at minimum = 1.00000000112345, f(1.00000000112345) = 5.04852568272458e-018 after 10 iterations.
505 Showing 53 bits precision with 9 decimal digits from tolerance 1.49011611938477e-008
506 x at minimum = 1, f(1) = 5.04852568e-018 after 10 iterations.
507 Showing 26 bits precision with 9 decimal digits from tolerance 0.000172633492
508 x at minimum = 1, f(1) = 5.04852568e-018
509 10 iterations.
510 Showing 13 bits precision with 9 decimal digits from tolerance 0.015625
511 x at minimum = 0.9999776, f(0.9999776) = 2.0069572e-009, after 7 iterations.
512 x at minimum = 1.00000000000137302, f(1.00000000000137302) = 7.5407901369731193e-024, after 10 iterations.
513
514
515 For type f,
516 epsilon = 1.1921e-007,
517 the maximum theoretical precision from Brent minimization is 0.00034527
518 Displaying to std::numeric_limits<T>::digits10 5 significant decimal digits.
519 x at minimum = 1.0002, f(1.0002) = 1.9017e-007,
520 met 12 bits precision, after 7 iterations.
521 x == 1 (compared to uncertainty 0.00034527) is true
522 f(x) == (0 compared to uncertainty 0.00034527) is true
523
524
525 For type d,
526 epsilon = 2.220446e-016,
527 the maximum theoretical precision from Brent minimization is 1.490116e-008
528 Displaying to std::numeric_limits<T>::digits10 7 significant decimal digits.
529 x at minimum = 1, f(1) = 5.048526e-018,
530 met 26 bits precision, after 10 iterations.
531 x == 1 (compared to uncertainty 1.490116e-008) is true
532 f(x) == (0 compared to uncertainty 1.490116e-008) is true
533
534
535 For type e,
536 epsilon = 1.084202e-019,
537 the maximum theoretical precision from Brent minimization is 3.292723e-010
538 Displaying to std::numeric_limits<T>::digits10 7 significant decimal digits.
539 x at minimum = 1, f(1) = 7.54079e-024,
540 met 32 bits precision, after 10 iterations.
541 x == 1 (compared to uncertainty 3.292723e-010) is true
542 f(x) == (0 compared to uncertainty 3.292723e-010) is true
543
544
545 For type N5boost14multiprecision6numberINS0_8backends16float128_backendELNS0_26expression_template_optionE0EEE,
546 epsilon = 1.92592994e-34,
547 the maximum theoretical precision from Brent minimization is 1.38777878e-17
548 Displaying to std::numeric_limits<T>::digits10 9 significant decimal digits.
549 x at minimum = 1, f(1) = 1.48695468e-43,
550 met 56 bits precision, after 12 iterations.
551 x == 1 (compared to uncertainty 1.38777878e-17) is true
552 f(x) == (0 compared to uncertainty 1.38777878e-17) is true
553 -4 1.3333333333333333333333333333333333333333333333333
554 x at minimum = 0.99999999999999999999999999998813903221565569205253, f(0.99999999999999999999999999998813903221565569205253) = 5.6273022712501408640665300316078046703496236636624e-58, after 14 iterations.
555
556
557 For type N5boost14multiprecision6numberINS0_8backends13cpp_bin_floatILj50ELNS2_15digit_base_typeE10EviLi0ELi0EEELNS0_26expression_template_optionE1EEE,
558 epsilon = 5.3455294202e-51,
559 the maximum theoretical precision from Brent minimization is 7.311312755e-26
560 Displaying to std::numeric_limits<T>::digits10 11 significant decimal digits.
561 x at minimum = 1, f(1) = 5.6273022713e-58,
562 met 84 bits precision, after 14 iterations.
563 x == 1 (compared to uncertainty 7.311312755e-26) is true
564 f(x) == (0 compared to uncertainty 7.311312755e-26) is true
565 -4 1.3333333333333333333333333333333333333333333333333
566 x at minimum = 0.99999999999999999999999999998813903221565569205253, f(0.99999999999999999999999999998813903221565569205253) = 5.6273022712501408640665300316078046703496236636624e-58
567 14 iterations.
568
569
570 For type N5boost14multiprecision6numberINS0_8backends13cpp_bin_floatILj50ELNS2_15digit_base_typeE10EviLi0ELi0EEELNS0_26expression_template_optionE1EEE,
571 epsilon = 5.3455294202e-51,
572 the maximum theoretical precision from Brent minimization is 7.311312755e-26
573 Displaying to std::numeric_limits<T>::digits10 11 significant decimal digits.
574 x at minimum = 1, f(1) = 5.6273022713e-58,
575 met 84 bits precision, after 14 iterations.
576 x == 1 (compared to uncertainty 7.311312755e-26) is true
577 f(x) == (0 compared to uncertainty 7.311312755e-26) is true
578
579 RUN SUCCESSFUL (total time: 90ms)
580
581
582 */