Skip to main content

fixed_point

Function fixed_point 

Source
pub fn fixed_point<G>(
    g: G,
    x0: f64,
    xtol: f64,
    maxiter: usize,
    method: FixedPointMethod,
) -> Result<f64, ErrorsJSL>
where G: Fn(f64) -> f64,
Expand description

Finds a fixed point of g from x0 (SciPy’s fixed_point). With FixedPointMethod::Del2 each step takes p₁ = g(p₀), p₂ = g(p₁) and extrapolates p = p₀ − (p₁ − p₀)²/(p₂ − 2p₁ + p₀) (or p₂ when the denominator vanishes), which converges quadratically even where plain iteration converges linearly — or not at all. Stops when the relative change |p/p₀ − 1| (|p| at p₀ = 0) is below xtol (SciPy: 10⁻⁸); errors after maxiter steps (SciPy: 500).