NAME
Math::Brent - Single Dimensional Function Minimisation
SYNOPSIS
use Math::Brent qw(Minimise1D);
my ($x, $y) = Minimise1D($guess, $scale, \&func, $tol, $itmax);
or
use Math::Brent qw(BracketMinimum Brent);
my ($ax, $bx, $cx, $fa, $fb, $fc) = BracketMinimum($ax, $bx, \&func);
my ($x, $y) = Brent($ax, $bx, $cx, \&func, $tol, $itmax);
DESCRIPTION
This is an implementation of Brent's method for One-Dimensional minimisation of a function without using derivatives. This algorithm cleverly uses both the Golden Section Search and parabolic interpolation.
FUNCTIONS
The functions may be imported by name, or by using the export tag "all".
Minimise1D()
Provides a simple interface to the "BracketMinimum()" and "Brent()" routines.
Given a function, an initial guess for the function's minimum, and its scaling, this routine converges to the function's minimum using Brent's method.
($x, $y) = Minimise1D($guess, $scale, \&func);
The minimum is reached within a certain tolerance (defaulting 1e-7), and attempts to do so within a maximum number of iterations (defaulting to 100). You may override them by providing alternate values:
($x, $y) = Minimise1D($guess, $scale, \&func, 1.5e-8, 120);
Brent()
Given a function and a triplet of abcissas $ax, $bx, $cx, such that
Brent() isolates the minimum to a fractional precision of about $tol using Brent's method.
A maximum number of iterations $itmax may be specified for this search - it defaults to 100. Returned is a list consisting of the abcissa of the minum and the function value there.
BracketMinimum()
Given a function reference \&func and distinct initial points $ax and $bx searches in the downhill direction (defined by the function as evaluated at the initial points) and returns a list of the three points $ax, $bx, $cx which bracket the minimum of the function and the function values at those points.
EXAMPLE
use Math::Brent qw(Minimise1D);
sub sinc {
my $x = shift ;
return $x ? sin($x)/$x: 1;
}
my($x, $y) = Minimise1D(1, 1, \&sinc, 1e-7);
print "Minimum is at sinc($x) = $y\n";
produces the output
Minimum is at sinc(4.4934094397196) = -.217233628211222
Anonymous subroutines may also be used as the function reference:
my $cubic_ref = sub {my($x) = @_; return 6.25 + $x*$x*(-24 + $x*8));};
my($x, $y) = Minimise1D(3, 1, $cubic_ref);
print "Minimum of the cubic at $x = $y\n";
BUGS
Please report any bugs or feature requests via Github's issues link
AUTHOR
John A.R. Williams J.A.R.Williams@aston.ac.uk
John M. Gamble jgamble@cpan.org (current maintainer)
SEE ALSO
"Numerical Recipies: The Art of Scientific Computing" W.H. Press, B.P. Flannery, S.A. Teukolsky, W.T. Vetterling. Cambridge University Press. ISBN 0 521 30811 9.
Richard P. Brent, Algorithms for Minimization Without Derivatives
Professor (Emeritus) Richard Brent has a web page at http://maths-people.anu.edu.au/~brent/