The OpenD Programming Language

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)
    Tuple!(T, T, R, R)
    findRoot
    (
    T
    R
    DF
    DT
    )
    (
    scope DF f
    ,
    const T ax
    ,
    const T bx
    ,
    const R fax
    ,
    const R fbx
    ,
    scope DT tolerance
    )
    if (
    is(typeof(tolerance(T.init, T.init)) : bool)
    &&
    is(typeof(f(T.init)) == R)
    &&
    )
  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)

Parameters

f DF

Function to be analyzed

ax T

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

bx T

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

fax R

Value of f(ax).

fbx R

Value of f(bx). fax and fbx should have opposite signs. (f(ax) and f(bx) are commonly known in advance.)

tolerance DT

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: Tuple!(T, T, R, R)

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