31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.17 Numerical Analysis Functions ( numerical<br />

analysis )<br />

We collect some functions of numerical analysis. <strong>The</strong> algorithms in this section are not<br />

the best known and are not recommended for serious use. We refer the reader to the book<br />

“Numerical Recipes in C: <strong>The</strong> Art of Scientific Computing” by B.P. Flannery, W.H. Press,<br />

S.A. Teukolsky, and W.T. Vetterling, Cambridge University Press for better algorithms.<br />

<strong>The</strong> functions in this section become available by including numerical analysis.h.<br />

5.17.1 Minima and Maxima<br />

double minimize function(double (∗f)(double), double& xmin, double tol = 1.0e − 10)<br />

finds a local minimum of the function f of one argument. <strong>The</strong><br />

minimizing argument is returned in xmin and the minimal<br />

function value is returned as the result of the function. xmin<br />

is determined with tolerance tol, i.e., the true value of the<br />

minimizing argument is contained in the interval [xmin(1 −<br />

ɛ), xmin(1 + ɛ)], where ɛ = max(1, xmin) · tol. Please do not<br />

choose tol smaller than 10 −15 .<br />

Precondition: : If +∞ or −∞ is a local minimum of f, then<br />

the call of minimize function may not terminate.<br />

<strong>The</strong> algorithm is implemented as follows: First three arguments<br />

are determined such that a < b < c (or a > b > c)<br />

and f(a) ≥ f(b) ≤ f(c), i.e., a and c bracket a minimum.<br />

<strong>The</strong> interval is found by first taking two arbitrary arguments<br />

and comparing their function values. <strong>The</strong> argument with<br />

the larger function value is taken as a. <strong>The</strong>n steps of larger<br />

and larger size starting at b are taken until a function value<br />

larger than f(b) is found. Once the bracketing interval is<br />

found, golden-ratio search is applied to it.<br />

template <br />

double minimize function(const F & f, double& xmin, double tol = 1.0e − 10)<br />

a more flexible version of the above. It is assumed that class<br />

F offers the operator<br />

double operator( )(double x). This operator is taken as the<br />

function f.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!