[frames] | no frames]

# Module root

source code

Solve a 1-dimensional equation to find the roots. This does alternating secant and bisection steps. It will work for any function, discontinuous or not. For a nasty function, it might be a factor of 2 slower than bisection, but for a nearly-linear function, it can be much faster than bisection.

Functions
float
 root(f, xl, xh, p, epsx, epsf) Find a root of an equation. source code

 test() source code

 iroot(y, xl, xh, epsy=0.0) Find a zero in an array y. source code

 testi() source code
 Variables __package__ = `None` hash(x)
 Function Details

### root(f, xl, xh, p, epsx, epsf)

source code

Find a root of an equation.

Parameters:
• `f` - is the function to solve, called as f(x, p).
• `p` - is arbitrary data for f. This function assumes there is known to be a root in [xl,xh] and that f(xl,p) has a different sign from f(xh,p). It finds it within a region of width epsx, or at least finds an x such that -epsf < f(x, p) < epsf .
Returns: float
a root in the interval

### iroot(y, xl, xh, epsy=0.0)

source code

Find a zero in an array y. This function assumes there is known to be a root in [xl,xh]. It returns a real-number index into the array which linearly interpolates to zero.

 Generated by Epydoc 3.0.1 on Thu Sep 22 04:25:02 2011 http://epydoc.sourceforge.net