Search
Documents
Math::Brent - Single Dimensional Function Minimisation (Displayed) README
|
Math::Brent - Single Dimensional Function Minimisation
use Math::Brent qw(FindMinima BracketMinimum Brent Minimise1D);
my ($x,$y)=Minimise1D($guess,$scale,\&func,$tol,$itmax);
my ($ax,$bx,$cx,$fa,$fb,$fc)=BracketMinimum($ax,$bx,$cx,\&func);
my ($x,$y)=Brent($ax,$bx,$cx,\&func,$tol,$itmax);
This is an implementation of Brents method for One-Dimensional
minimisation of a function without using derivatives. This algorithm
cleverly uses both the Golden Section Search and parabolic
interpolation.
The main function Brent, given a function reference \&func and a
bracketing triplet of abcissas $ax, $bx, $cx (such that
$bx is between $ax and $cx and func($bx) is less than both
func($ax) and func($cx)), isolates the minimum to a fractional
precision of about $tol using Brents method. A maximum number of
iterations $itmax may be specified for this search - it defaults to
100. Returned is an array consisting of the abcissa of the minum and
the function value there.
The function BracketMinimum, given a function \&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 an array of the three points $ax, $bx, $cx which
bracket the minimum of the function and the function values at those
points.
The function Minimise1D provides a simple interface to the above
two routines. Given a function \&func, an initial guess for its
minimum, and its scaling ($guess,$scale) this routine isolates
the minimum to a fractional precision of about $tol using Brents
method. A maximum number of iterations $itmax may be specified for
this search - it defaults to 100. It returns an array consisting of
the abcissa of the minum and the function value there.
use Math::Brent qw(Minimise1D);
sub func {
my $x=shift ;
return $x ? sin($x)/$x: 1;
}
my ($x,$y)=Minimise1D(1,1,\&func,1e-7);
print "Minimum is func($x)=$y\n";
produces the output
Minimum is func(5.236068)=-.165388470697432
=head1 HISTORY
$Log: Brent.pm,v $
Revision 1.1 1995/12/26 10:06:36 willijar
Initial revision
Let me know of any problems.
John A.R. Williams <J.A.R.Williams@aston.ac.uk>
``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.
Information
|
This site is currently in testing, it is not yet operating using the full database. Until it is officially launched you may wish to visit Help-Site Computer Manuals. After launch, this site (HelpSpy) will replace Help-Site. Information about the spider which is currently trawling the Internet looking for links to add to this directory can be found here. |
|
|