org.apache.commons.math3.analysis.solvers

## Class NewtonSolver

- java.lang.Object
- - org.apache.commons.math3.analysis.solvers.BaseAbstractUnivariateSolver<DifferentiableUnivariateFunction>
  - - org.apache.commons.math3.analysis.solvers.AbstractDifferentiableUnivariateSolver
    - - org.apache.commons.math3.analysis.solvers.NewtonSolver

- All Implemented Interfaces:
    BaseUnivariateSolver<DifferentiableUnivariateFunction>, DifferentiableUnivariateSolver

      public class NewtonSolver
      extends AbstractDifferentiableUnivariateSolver

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

  The function should be continuous but not necessarily smooth.

  Version:
    $Id: NewtonSolver.java 1244107 2012-02-14 16:17:55Z erans $

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `NewtonSolver()` Construct a solver.
    `NewtonSolver(double absoluteAccuracy)` Construct a solver.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected double` | `doSolve()` Method for implementing actual optimization algorithms in derived classes.
    `double` | `solve(int maxEval, DifferentiableUnivariateFunction f, double min, double max)` Find a zero near the midpoint of `min` and `max`.

    - ### Methods inherited from class org.apache.commons.math3.analysis.solvers.AbstractDifferentiableUnivariateSolver

      `computeDerivativeObjectiveValue, setup`

    - ### Methods inherited from class org.apache.commons.math3.analysis.solvers.BaseAbstractUnivariateSolver

      `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.math3.analysis.solvers.BaseUnivariateSolver

      `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,
                     DifferentiableUnivariateFunction f,
                     double min,
                     double max)

      Find a zero near the midpoint of `min` and `max`.
      Specified by:
        `solve` in interface `BaseUnivariateSolver<DifferentiableUnivariateFunction>`
      Overrides:
        `solve` in class `BaseAbstractUnivariateSolver<DifferentiableUnivariateFunction>`
      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 `BaseAbstractUnivariateSolver<DifferentiableUnivariateFunction>`
      Returns:
        the root.

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