org.apache.commons.math.analysis.solvers
Class NewtonSolver

java.lang.Object
  extended by org.apache.commons.math.analysis.solvers.BaseAbstractUnivariateRealSolver<DifferentiableUnivariateRealFunction>
      extended by org.apache.commons.math.analysis.solvers.AbstractDifferentiableUnivariateRealSolver
          extended by org.apache.commons.math.analysis.solvers.NewtonSolver
All Implemented Interfaces:
BaseUnivariateRealSolver<DifferentiableUnivariateRealFunction>, DifferentiableUnivariateRealSolver

public class NewtonSolver
extends AbstractDifferentiableUnivariateRealSolver

Implements Newton's Method for finding zeros of real univariate functions.

The function should be continuous but not necessarily smooth.

Version:
$Id: NewtonSolver.java 1143729 2011-07-07 09:36:54Z erans $

Constructor Summary
NewtonSolver()
          Construct a solver.
NewtonSolver(double absoluteAccuracy)
          Construct a solver.
 
Method Summary
protected  double doSolve()
          Method for implementing actual optimization algorithms in derived classes.
 double solve(int maxEval, DifferentiableUnivariateRealFunction f, double min, double max)
          Find a zero near the midpoint of min and max.
 
Methods inherited from class org.apache.commons.math.analysis.solvers.AbstractDifferentiableUnivariateRealSolver
computeDerivativeObjectiveValue, setup
 
Methods inherited from class org.apache.commons.math.analysis.solvers.BaseAbstractUnivariateRealSolver
computeObjectiveValue, getAbsoluteAccuracy, getEvaluations, getFunctionValueAccuracy, getMax, getMaxEvaluations, getMin, getRelativeAccuracy, getStartValue, incrementEvaluationCount, isBracketing, isSequence, solve, solve, verifyBracketing, verifyInterval, verifySequence
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.math.analysis.solvers.BaseUnivariateRealSolver
getAbsoluteAccuracy, getEvaluations, getFunctionValueAccuracy, getMaxEvaluations, getRelativeAccuracy, solve, solve
 

Constructor Detail

NewtonSolver

public NewtonSolver()
Construct a solver.


NewtonSolver

public NewtonSolver(double absoluteAccuracy)
Construct a solver.

Parameters:
absoluteAccuracy - Absolute accuracy.
Method Detail

solve

public double solve(int maxEval,
                    DifferentiableUnivariateRealFunction f,
                    double min,
                    double max)
Find a zero near the midpoint of min and max.

Specified by:
solve in interface BaseUnivariateRealSolver<DifferentiableUnivariateRealFunction>
Overrides:
solve in class BaseAbstractUnivariateRealSolver<DifferentiableUnivariateRealFunction>
Parameters:
f - Function to solve.
min - Lower bound for the interval.
max - Upper bound for the interval.
maxEval - Maximum number of evaluations.
Returns:
the value where the function is zero.
Throws:
TooManyEvaluationsException - if the maximum evaluation count is exceeded.
NumberIsTooLargeException - if min >= max.

doSolve

protected double doSolve()
Method for implementing actual optimization algorithms in derived classes.

Specified by:
doSolve in class BaseAbstractUnivariateRealSolver<DifferentiableUnivariateRealFunction>
Returns:
the root.


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.