Previous topic

mmf.signal.spectrum

Next topic

mmf.solve.broyden

This Page

mmf.solve

broyden Broyden Root Finders.
broyden_solvers Iterative solvers based on the Broyden method.
solver_interface This module contains the interface for solving root-finding and.or
solver_utils Solver Utilities.
solvers Iterative solvers.
test_problems Test problems for testing non-linear solvers.
ceil_root(f[, N_min, max_steps]) Return the smallest integer N >= N_min such that f(N) >= 0.
bracket_root(f[, a, b, factor, ntry]) Return a pair ([a, b, ...], [f(a), f(b), ...]) such that a < b and f(a)*f(b) <= 0 (i.e.

Non-linear solvers.

This module provides several non-linear solvers implementing the various interfaces defined in solver_interface, in particular

solver_interface.IProblem() Interface for an iterative problem: the solver’s goal is to
solver_interface.IState() Interface for the state of a solution.
solver_interface.ISolver(state0) Interface for solver objects.

Some solver utilities.

mmf.solve.ceil_root(f, N_min=0, max_steps=1000)

Return the smallest integer N >= N_min such that f(N) >= 0.

Assumes that f(N) is monotonically increasing.

Parameters :

f : f(int) -> float

Monotonically increasing fitness function

N_min : int

Minimum solution

max_steps : int

Maximum number of steps to take before bailing out.

Examples

>>> def f(N): return 3.14159*N - 7.0
>>> ceil_root(f)
3
>>> def f(N): return N-10
>>> ceil_root(f)
10
>>> def f(N): return 3.14159*N - 3.0
>>> ceil_root(f, 1)
1
mmf.solve.bracket_root(f, a=None, b=None, factor=1.6, ntry=50)

Return a pair ([a, b, ...], [f(a), f(b), ...]) such that a < b and f(a)*f(b) <= 0 (i.e. a and b bracket a sign-change (a “root”))

The lists contain all the points at which the function was evaluated so that these may be used to save time...

>>> from math import *
>>> f = sin
>>> (x, fx) = bracket_root(f, 0.1)
>>> x[0]<x[1]
True
>>> fx[0]*fx[1] <= 0 
True
>>> max([abs(fx1-fx2) for (fx1, fx2) in zip(map(f, x), fx)])
0.0