The OpenD Programming Language

findLocalMin

Find a real minimum of a real function f(x) via bracketing. Given a function f and a range (ax .. bx), returns the value of x in the range which is closest to a minimum of f(x). f is never evaluted at the endpoints of ax and bx. If f(x) has more than one minimum in the range, one will be chosen arbitrarily. If f(x) returns NaN or -Infinity, (x, f(x), NaN) will be returned; otherwise, this algorithm is guaranteed to succeed.

findLocalMin
(
T
)
(
const T ax
,
const T bx
,
const T relTolerance = sqrt(T.epsilon)
,
const T absTolerance = sqrt(T.epsilon)
,
size_t N = 0
)
if (
isFloatingPoint!T &&
__traits(compiles, T(f(T.init)))
)

Parameters

f

Function to be analyzed

ax T

Left bound of initial range of f known to contain the minimum.

bx T

Right bound of initial range of f known to contain the minimum.

relTolerance T

Relative tolerance.

absTolerance T

Absolute tolerance.

N size_t

number of addition inner points of uniform grid. The algorithm computes function value for the N points. Then reassing ax to the point that preceeds the grid's argmin, reassing bx to the point that follows the the grid's argmin. The search interval reduces (N + 1) / 2 times. Preconditions: ax and bx shall be finite reals.
relTolerance shall be normal positive real.
absTolerance shall be normal positive real no less then T.epsilon*2.

Return Value

Type: FindLocalMinResult!T

A FindLocalMinResult consisting of x, y = f(x) and error = 3 * (absTolerance * fabs(x) + relTolerance). The method used is a combination of golden section search and successive parabolic interpolation. Convergence is never much slower than that for a Fibonacci search. References: "Algorithms for Minimization without Derivatives", Richard Brent, Prentice-Hall, Inc. (1973)

See Also

Meta