NMath User's Guide

TOC | Previous | Next | Index

26.1 Bracketing a Minimum (.NET, C#, CSharp, VB, Visual Basic, F#)

Minima of univariate functions must be bracketed before they can be isolated. A bracket is a triplet of points, xlower < xinterior < xupper, such that f(xinterior) < f(xlower) and f(xinterior) < f(xupper). These conditions ensure that there is some local minimum in the interval (xlower,xupper,).

If you know in advance that a local minimum falls within a given interval, you can simply call the NMath minimization routines using that interval. Before beginning minimization, the routine will search for an interior point that satisfies the bracketing condition.

Otherwise, construct a Bracket object. Beginning with a pair of points, Bracket searches in the downhill direction for a new pair of points that bracket a minimum of a function. For example, if function is a OneVariableFunction:

Code Example – C# minimization

var bracket = new Bracket( function, 0, 1 );

Code Example – VB minimization

Dim Bracket As New Bracket( MyFunction, 0, 1 )

Once constructed, a Bracket object provides the following properties:

Function gets the function whose minimum is bracketed.

Lower gets a lower bound on a minimum of the function.

Upper gets an upper bound on a minimum of the function.

Interior gets a point between the lower and upper bound such that xlower < xinterior < xupper, f(xinterior) < f(xlower), and f(xinterior) < f(xupper)

FLower gets the function evaluated at the lower bound.

FUpper gets the function evaluated at the upper bound.

FInterior gets the function evaluated at the interior point.