## Series

**numerics4j** provides the means to create and evaluate infinite series. The following routines are available for series evaluation:

Method | Description |
---|---|

Power Series | Specialized series implementation devoted to power series evaluation. |

Series | A pure infinite series where terms are functions of their index and point of evaluation. If none of the other series methods satisfy your needs, this series implementation should be flexible enough to accomodate any situation. |

### Power Series

**numerics4j** provides the means to create and evaluate infinite
power series. See
Power Series
for an in depth definition of infinite power series. To create a power
series, simply subclass
PowerSeries
and provide an implementation for the getTerm method, which returns the series terms.

For example, the exponetial function can be evaulated with a power series:

PowerSeries exponential = new PowerSeries() { public double getTerm(int n) { return 1.0 / factorial(n); } private double factorial(int n) { double p = 1.0; for(int i = n; i > 0; --i) { p *= i; } return p; } }; double x = exponential.evaluate(2.0); // Math.exp(2.0) double x = exponential.evaluate(4.0); // Math.exp(4.0)

### Series

**numerics4j** provides the means to create and evaluate infinite
series. See
Series
for an in depth definition of infinite series. To create a series,
simply subclass
Series
and provide an implementation for the getTerm method,
which returns the series terms.

The Series class is flexible with regards to the variety of convergent, infinite series it can represent. For example it can be used on geometric series, ones whose ratio of consecutive terms is constant like "the" geometric series:

Series geometric = new Series() { public double getTerm(int n, double x) { return Math.pow(.5, n); } }; double x = geometric.evaluate(0.0); // returns 2.0 for all input values.

Also, the Series class can represent series whose terms are not only functions of their indices, but also functions of an evaluation point. A lot of common series fit this general definition including power series and Taylor series. As such, these series can be evaluated numerically using the Series class. For example, the exponetial function can be evaluated with a series:

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; for(int i = n; i > 0; --i) { p *= i; } return p; } }; double x = exponential.evaluate(2.0); // Math.exp(2.0) double x = exponential.evaluate(4.0); // Math.exp(4.0)