Series

numerics4net 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

numerics4net 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 create a new numerics4net.series.PowerSeries instance providing a delegate which returns the series terms.

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

PowerSeries exponential = new PowerSeries(new PowerSeries.Term(ExponentialTerm));

double ExponetialTerm(int n) {
    return 1.0 / Factorial(n);
}

double Factorial(int n) {
    double p = 1.0;
    for(uint i = n; i > 0; --i) {
        p *= i;
    }
    return p;
}

double x = exponential.evaluate(2.0); // Math.Exp(2.0)
       x = exponential.evaluate(4.0); // Math.Exp(4.0)

Series

numerics4net provides the means to create and evaluate infinite series. See Series for an in depth definition of infinite series. To create a series, simply create a new numerics4net.series.Series instance providing a delegate 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:

double GeometricTerm(uint n, double x) {
    return Math.pow(.5, n);
}

Series.Term term = new Series.Term(GeometricTerm);
Series geometric = new Series(term);

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:

double ExponetialTerm(uint n, double x) {
    return Math.Pow(x, n) / Factorial(n);
}

double Factorial(uint n) {
    double p = 1.0;
    for(uint i = n; i > 0; --i) {
        p *= i;
    }
    return p;
}

Series.Term term = new Series.Term(ExponentialTerm);
Series exponential = new Series(term);

double x = exponential.Evaluate(2.0); // Math.Exp(2.0)
double x = exponential.Evaluate(4.0); // Math.Exp(4.0)