The Commons Math User Guide - Numerical Analysis Phil Steitz

This is yet to be written. Any contributions will be gratefully accepted!

org.apache.commons.math.analysis.UnivariateRealSolver provides the means to find roots of univariate, real valued, functions. Commons-Math supports various implementations of UnivariateRealSolver to solve functions with differing characteristics.

In order to use the root-finding features, first a solver object must be created. It is encouraged that all solver object creation occurs via the org.apache.commons.math.analysis.UnivariateRealSolverFactory class. UnivariateRealSolverFactory is a simple factory used to create all of the solver objects supported by Commons-Math. The typical usage of UnivariateRealSolverFactory to create a solver object would be:

UnivariateRealFunction function = // some user defined function object UnivariateRealSolverFactory factory = UnivariateRealSolverFactory.newInstance(); UnivariateRealSolver solver = factory.newDefaultSolver(function);

The solvers that can be instantiated via the UnivariateRealSolverFactory are detailed below:
SolverFactory MethodNotes on Use
BisectionnewBisectionSolver
Root must be bracketted.
Linear, guaranteed convergence
BrentnewBrentSolver
Root must be bracketted.
Super-linear, guaranteed convergence
SecantnewSecantSolver
Root must be bracketted.
Super-linear, non-guaranteed convergence

Using a solver object, roots of functions are easily found using the solve methods. For a function f, and two domain values, min and max, solve computes the value c such that:

  • f(c) = 0.0
  • min <= c <= max

UnivariateRealFunction function = // some user defined function object UnivariateRealSolverFactory factory = UnivariateRealSolverFactory.newInstance(); UnivariateRealSolver solver = factory.newBisectionSolver(function); double c = solver.solve(1.0, 5.0);

Along with the solve methods, the UnivariateRealSolver interface provides many properties to control the convergence of a solver. For the most part, these properties should not have to change from their default values to produce quality results. In the circumstances where changing these property values is needed, it is easily done through getter and setter methods on UnivariateRealSolver:
PropertyMethodsPurpose
Absolute accuracy
getAbsoluteAccuracy
resetAbsoluteAccuracy
setAbsoluteAccuracy
This is yet to be written. Any contributions will be greatfully accepted!
Function value accuracy
getFunctionValueAccuracy
resetFunctionValueAccuracy
setFunctionValueAccuracy
This is yet to be written. Any contributions will be greatfully accepted!
Maximum iteration count
getMaximumIterationCount
resetMaximumIterationCount
setMaximumIterationCount
This is yet to be written. Any contributions will be greatfully accepted!
Relative accuracy
getRelativeAccuracy
resetRelativeAccuracy
setRelativeAccuracy
This is yet to be written. Any contributions will be greatfully accepted!

This is yet to be written. Any contributions will be gratefully accepted!