Pourvu que l'on ait une auge, on trouvera les cochons.
Name
brent — find the minimum of a function with Brent's method of golden section search accelerated by inverse quadratic interpolation.
Synopsis
#include <brent.h>
int (objective_t)( 
double x, 
void * arg,  
double * fx) ; 
extern int brent( 
objective_t * f, 
void * arg,  
const double bracket[static 3],  
const brent_opt_t * opt,  
double * x0,  
brent_stat_t * stat) ; 
extern const char * brent_strerror
( 
int errorcode) ; 
DESCRIPTION
The brent
function calculates the value x0
which minimises a function f
over the range
specified by a given bracket
.
The parameters, in detail, are:
 objective_t*
f

A function with prototype objective_t as in the synopsis above, for which the minimiser is sought. With arguments:
 double
x

the argument of the function
f
;  void *
arg

used to pass other contextual data to the function
f
;  double *
fx

the result of applying function, assigned on success.
The function should return an int which is zero on success and nonzero otherwise.
 double
 void *
arg

Context which will be passed to the objective function
f
. This may beNULL
if the objective does not use it (to be precise, if it does not dereference it).  double
bracket
[static 3] 
A pointer to an array of three doubles: these should be in increasing order and the outer pair are used to bound the search for a minimiser. The middle value is used as the starting point for the search — if one has no a priori reason to use a particular value then the midpoint is a good choice.
 brent_opt_t
opt

A pointer to a structure of type brent_opt_t used to control the behaviour of the algorithm. This struct has members
 double
tolerance

The desired absolute accuracy of the minimiser
x0
.  size_t
max_iterations

The maximum number of iterations to use.
The value
NULL
is permitted, and in this case sensible defaults are used.  double
 double *
x0

A pointer to which the minimising value will be written if the algorithm converges.
 brent_stat_t *
stat

A pointer (possibly
NULL
) to a structure used to report details of the algorithm's execution. This struct has members: double
minimum

The value of the objective function
f
at the minimiserx0
.  size_t
iterations

The number of iterations used.
 size_t
evaluations

The number of function evaluations used.
The struct is only written if the algorithm converges (i.e., when
BRENT_OK
is returned).  double