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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5.17.2 Integration<br />

double integrate function(double (∗f)(double), double l, double r,<br />

double delta = 1.0e − 2)<br />

Computes the integral of f in the interval [l, r] by forming<br />

the sum delta∗ ∑ 0≤i 0.<br />

template <br />

double integrate function(const F & f, double l, double r, double delta = 1.0e − 2)<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.<br />

5.17.3 Useful Numerical Functions<br />

double binary entropy(double x)<br />

returns the binary entropy of x, i.e., −x · log x − (1 − x) ·<br />

log(1 − x).<br />

Precondition: 0 ≤ x ≤ 1.<br />

5.17.4 Root Finding<br />

double zero of function(double (∗f)(double), double l, double r, double tol = 1.0e − 10)<br />

returns a zero x of f. We have either |f(x)| ≤ 10 −10 or there<br />

is an interval [x 0 , x 1 ] containing x such that f(x 0 )·f(x 1 ) ≤ 0<br />

and x 1 − x 0 ≤ tol · max(1, |x 1 | + |x 1 |).<br />

Precondition: l ≤ r and f(l) · f(r) ≤ 0.<br />

template <br />

double zero of function(const F & f, double l, double r, 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!