|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.doodleproject.numerics4j.IterativeMethod net.sf.doodleproject.numerics4j.series.Series
public abstract class Series
This class provides the means to evaluate infinite series (1). To create a series, authors subclass this class and provided a concrete term method. Of note, when evaluating a series, the term indicies are the nonnegative integers. That is to say, the first term is at index zero and each subsequent term increases the index by one. It is the responsibility of the author to shift term indices as needed if a series does not start at zero or if the indices are not unit increments.
For example, this is the series for the exponential function defined by (2):
Series exponential = new Series() { public double getTerm(int n, double x) { return Math.pow(x, n) / factorial(n); } private double factorial(int n) { double p = 1.0; while(n > 1.0) { p *= n--; } return p; } }
References:
Nested Class Summary | |
---|---|
(package private) class |
Series.IterativeState
The internal state used during series evaluation. |
Constructor Summary | |
---|---|
protected |
Series()
Default constructor. |
protected |
Series(int iterations,
double error)
Create a series with the given number of maximum iterations and maximum relative error. |
protected |
Series(int index,
int iterations,
double error)
Create a series with the given first term index, number of maximum iterations and maximum relative error. |
Method Summary | |
---|---|
double |
evaluate(double x)
Evaluate this series at the given value. |
protected abstract double |
getTerm(int n,
double x)
Access the n-th term for this series. |
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 |
---|
protected Series()
protected Series(int iterations, double error)
iterations
- maximum number of iterations.error
- maximum relative error.protected Series(int index, int iterations, double error)
index
- index of first term in this series.iterations
- maximum number of iterations.error
- maximum relative error.Method Detail |
---|
public double evaluate(double x) throws NumericException
x
- the point of evalutation.
NumericException
- if the series could not be evaluated.protected abstract double getTerm(int n, double x)
n
- the term index.x
- the series evaluation point.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |