Class FalsePosition
The false-position one-dimensional solver.
public sealed class FalsePosition : Solver1D<FalsePosition, ISolver1DFunction>
- Inheritance
-
FalsePosition
- Inherited Members
Constructors
FalsePosition()
public FalsePosition()
Methods
Solve(Func<double, double>, double, double, double)
Solves f(x) = 0 near guess, bracketing the root by steps.
public double Solve(Func<double, double> f, double accuracy, double guess, double step)
Parameters
fFunc<double, double>The function.
accuracydoubleThe accuracy in x, positive.
guessdoubleThe first guess.
stepdoubleThe bracketing step.
Returns
- double
The root.
Exceptions
- ArgumentNullException
fis null.- ArgumentException
The accuracy isn't positive.
- NanoQLException
No bracket is found, or the evaluations run out.
Solve(Func<double, double>, double, double, double, double)
Solves f(x) = 0 in [xMin, xMax].
public double Solve(Func<double, double> f, double accuracy, double guess, double xMin, double xMax)
Parameters
fFunc<double, double>The function.
accuracydoubleThe accuracy in x, positive.
guessdoubleThe first guess, inside the bracket.
xMindoubleThe bracket's low end.
xMaxdoubleThe bracket's high end.
Returns
- double
The root.
Exceptions
- ArgumentNullException
fis null.- ArgumentException
The accuracy, bracket or guess is invalid.
- NanoQLException
The root isn't bracketed, or the evaluations run out.
SolveCore<TF>(TF, double, Solver1DBracket)
The solver's algorithm, QuantLib's solveImpl: the zero of f within the bracket the
public Solve found or checked.
protected override double SolveCore<TF>(TF f, double xAccuracy, Solver1DBracket bracket) where TF : struct, ISolver1DFunction
Parameters
fTFThe function.
xAccuracydoublebracketSolver1DBracketThe bracket, the function's values at its ends, the initial guess and the evaluations so far.
Returns
- double
The zero.
Type Parameters
TFThe function's type.