public class IntervalBisection extends Object implements CompositeFunction<Double,QuantitativeFunction<Double,Double>>
IntervalBisection.PrecisionStrategy.BETWEEN_RESULTS
) or the value is
within the desired distance of root (if configured with IntervalBisection.PrecisionStrategy.TO_INTERVAL
.
PrecisionStrategy defaults to IntervalBisection.PrecisionStrategy.TO_INTERVAL
, the method defaults to 20 iterations,
and an accuracy distance of 1e-3 (0.001).
Inspired by the example that appears in Java Methods for Financial Engineering (Philip Barker),
this implementation includes error handling, a functional programming model and two precision
strategies.Modifier and Type | Class and Description |
---|---|
static class |
IntervalBisection.PrecisionStrategy |
Constructor and Description |
---|
IntervalBisection(double lowerBound,
double higherBound) |
IntervalBisection(double lowerBound,
double higherBound,
int iterations)
Create a new instance with the given number of iterations and precision
|
IntervalBisection(double lowerBound,
double higherBound,
int iterations,
double precision,
IntervalBisection.PrecisionStrategy precisionStrategy)
Create a new instance with the given number of iterations and precision
|
Modifier and Type | Method and Description |
---|---|
Double |
apply(QuantitativeFunction<Double,Double> computeFunction)
Apply a function to the input argument T, yielding an appropriate result R.
|
double |
getHigherBound() |
int |
getIterations() |
double |
getLowerBound() |
double |
getPrecision() |
public IntervalBisection(double lowerBound, double higherBound)
public IntervalBisection(double lowerBound, double higherBound, int iterations)
lowerBound
- The minimum bound for the range to converge fromhigherBound
- The maximum bound for the range to converge fromiterations
- The number of iterations to performpublic IntervalBisection(double lowerBound, double higherBound, int iterations, double precision, IntervalBisection.PrecisionStrategy precisionStrategy)
lowerBound
- The minimum bound for the range to converge fromhigherBound
- The maximum bound for the range to converge fromiterations
- The number of iterations to performprecision
- The requested precisionprecisionStrategy
- Indicates approach for managing precisionpublic double getLowerBound()
public double getHigherBound()
public int getIterations()
public double getPrecision()
public Double apply(QuantitativeFunction<Double,Double> computeFunction)
CompositeFunction
apply
in interface CompositeFunction<Double,QuantitativeFunction<Double,Double>>
apply
in interface QuantitativeFunction<Double,QuantitativeFunction<Double,Double>>
computeFunction
- the input valueCopyright © 2010–2018 Jadira Systems. All rights reserved.