public class NewtonRaphsonSolver
extends java.lang.Object
The method tries to evaluate a function of the form f(x) - constant = 0. The user supplies the constant and an initial guess of x, x_0. The point where the tangent to f(x_0), f\prime(x_0), crosses the x-axis is taken to be closer to the solution. Therefore, x_1 = x_0 - \frac{f(x_0)}{f\prime(x_0)}. The process is continued until \mid\frac{ x_{i+1} - x_i }{ x_{i+1} }\mid \times 100 \leq maxEpsilon, where maxEpsilon is a user supplied parameter.
sphereDistFit.SVAnalyticalFunction
Constructor and Description |
---|
NewtonRaphsonSolver() |
Modifier and Type | Method and Description |
---|---|
static double |
solve(SVAnalyticalFunction f,
double c,
double x0,
double maxEpsilon)
Solve the function f(x) - c = 0.
|
public static double solve(SVAnalyticalFunction f, double c, double x0, double maxEpsilon) throws ConvergenceException
f
- must be a differentiable function.c
- the known value of f(x) for unknown x.x0
- the initial guess for x.maxEpsilon
- the maximum acceptable error (see class comment for definition).ConvergenceException
- if after 1000 iterations, convergence has not been reached.