cape.attdb.froot: Nonlinear equation solver

This module provides a function froot1() to solve nonlinear equations

\[f(x) = 0\]

where both x and the output of f can be either scalars or vectors. The function operates without attempting to use exact derivative or gradient information.

cape.attdb.froot.froot1(f, x0, *a, **kw)

Find a root of a real-valued scalar nonlinear function

Call:
>>> x = froot1(f, x0, **kw)
>>> x = froot1(f, x0, x1, **kw)
Inputs:
f: func

Function which can evaluate f(x0)

x0: float

Initial guess, scalar or vector

x1: class(x0)

(Optional) secondary guess to scale initial step or bracket

xtol, TolX: {1e-14} | float

Tolerance in x

ytol, TolFun: {1e-14} | float

Tolerance for absolute value of f(x)

imax, MaxIter: {80} | int

Maximum iterations

fmax, MaxFunEvals: {161} | int

Maximum function evaluations

y0: {None} | float

Optional evaluation of f(x0) to reduce func evals by one

v, DisplayTrue | {False}

Display iterative histories to STDOUT

Outputs:
x: float

Solution such that f(x) is approximately zero

Versions:
  • 2010-03-13 @ddalle: Optimized scalar root search

  • 2018-07-24 @ddalle: Ported to Python (from MATLAB)