findRoot

Find root of a real function f(x) by bracketing, allowing the termination condition to be specified.

  1. T findRoot(DF f, T a, T b, DT tolerance)
  2. T findRoot(DF f, T a, T b)
  3. Tuple!(T, T, R, R) findRoot(DF f, T ax, T bx, R fax, R fbx, DT tolerance)
  4. Tuple!(T, T, R, R) findRoot(DF f, T ax, T bx, R fax, R fbx)
  5. T findRoot(R delegate(T) f, T a, T b, bool delegate(T lo, T hi) tolerance)
    T
    findRoot
    (
    T
    R
    )
    (
    scope R delegate
    (
    T
    )
    f
    ,
    const T a
    ,
    const T b
    ,
    scope bool delegate
    (
    T lo
    ,
    T hi
    )
    tolerance = 
    (
    T a
    ,
    T b
    )
    => false
    )

Parameters

f R delegate
(
T
)

Function to be analyzed

tolerance bool delegate
(
T lo
,
T hi
)

Defines an early termination condition. Receives the current upper and lower bounds on the root. The delegate must return true when these bounds are acceptable. If this function always returns false, full machine precision will be achieved.

Return Value

Type: T

A tuple consisting of two ranges. The first two elements are the range (in x) of the root, while the second pair of elements are the corresponding function values at those points. If an exact root was found, both of the first two elements will contain the root, and the second pair of elements will be 0.

Meta