ca.nengo.math.impl
Class NewtonRootFinder

java.lang.Object
  extended by ca.nengo.math.impl.NewtonRootFinder
All Implemented Interfaces:
RootFinder

public class NewtonRootFinder
extends java.lang.Object
implements RootFinder

Root finder that uses Newton's method. Assumes that functions are generally increasing. TODO: test

Author:
Bryan Tripp

Constructor Summary
NewtonRootFinder(int maxIterations, boolean additiveBoundarySearch)
           
 
Method Summary
 float findRoot(Function function, float startLow, float startHigh, float tolerance)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NewtonRootFinder

public NewtonRootFinder(int maxIterations,
                        boolean additiveBoundarySearch)
Parameters:
maxIterations - Maximum search iterations to attempt before returning an error
additiveBoundarySearch - If true, when low and high boundaries need to be widened, a proportion of their difference is added/substracted. If false, they are multiplied/divided by a constant. False is a good idea for boundaries that should not cross zero.
Method Detail

findRoot

public float findRoot(Function function,
                      float startLow,
                      float startHigh,
                      float tolerance)
Specified by:
findRoot in interface RootFinder
Parameters:
function - Function f(x) to find root of
startLow - Low-valued x from which to start search
startHigh - High-valued x from which to start. You typically give startLow and startHigh so that you expect the signs of the functions at these values to be different.
tolerance - Max acceptable |f(x)| for which to return x
Returns:
x for which |f(x)| <= tolerance
See Also:
RootFinder.findRoot(ca.nengo.math.Function, float, float, float)