|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.doodleproject.numerics4j.IterativeMethod
net.sf.doodleproject.numerics4j.root.FalsePositionRootFinder
public class FalsePositionRootFinder
The false position method (1) for finding roots of functions.
For example, to find roots for sine, first a
Function is defined:
Function sine = new Function() {
public double evaluate(double x) {
return Math.sin(x);
}}
};
Then, a false position root finder is created with the above function:
FalsePositionRootFinder finder = new FalsePositionRootFinder(sine);
Lastly, locating roots is accomplished using the findRoot(double, double) method:
// find the root between 3 and 4. double pi = finder.findRoot(3.0, 4.0); // find the root between -1 and 1. double zero = finder.findRoot(-1.0, 1.0);
References:
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class net.sf.doodleproject.numerics4j.IterativeMethod |
|---|
IterativeMethod.IterativeState |
| Constructor Summary | |
|---|---|
FalsePositionRootFinder(Function f)
Create a root finder for the given function. |
|
FalsePositionRootFinder(Function f,
int iterations,
double error)
Create a root finder for the given function. |
|
| Method Summary | |
|---|---|
double |
findRoot(double min,
double max)
Find a root of the target function that lies in the interval [ min, max]. |
Function |
getFunction()
Access the target function. |
void |
setFunction(Function f)
Modify the target function. |
| Methods inherited from class net.sf.doodleproject.numerics4j.IterativeMethod |
|---|
getMaximumIterations, getMaximumRelativeError, iterate, setMaximumIterations, setMaximumRelativeError |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FalsePositionRootFinder(Function f)
f - the target function.
public FalsePositionRootFinder(Function f,
int iterations,
double error)
f - the target function.iterations - maximum number of iterations.error - maximum relative error.| Method Detail |
|---|
public double findRoot(double min,
double max)
throws NumericException
min - the lower bound of the search interval.max - the upper bound of the search interval.
NumericException - if a root could not be found.public Function getFunction()
public void setFunction(Function f)
f - the new target function.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||