brentq#

swordfish.function.brentq()#

Find a root x0 of a function f in a bracketing interval [a, b] using Brent’s method.

Parameters:
  • f (Constant) – A function which returns a number. The function fmust be continuous in [a,b], and f(a) and f(b) must have opposite signs.

  • a (Constant) – A numeric scalar that specifies the left boundary of the bracketing interval [a,b].

  • b (Constant) – A numeric scalar that specifies the right boundary of the bracketing interval [a,b].

  • xtol (Constant, optional) – A numeric scalar that specify the precision of the computed root, by default DFLT. The computed root x0 satisfies |x-x0| <= (xtol + rtol* |x0|), where x is the exact root. The default value of xtol is 2e-12, and the default value of rtol is 4 times the machine epsilon in double precision.

  • rtol (Constant, optional) – A numeric scalar that specify the precision of the computed root, by default DFLT. The computed root x0 satisfies |x-x0| <= (xtol + rtol* |x0|), where x is the exact root. The default value of xtol is 2e-12, and the default value of rtol is 4 times the machine epsilon in double precision.

  • maxIter (Constant, optional) – An integer indicating the maximum iterations, by default DFLT

  • funcDataParam (Constant, optional) – A vector containing extra arguments for the function f, by default DFLT

Returns:

A vector res of length 2.

Return type:

Constant