Class GeometricSeries

java.lang.Object
org.episteme.core.mathematics.analysis.series.GeometricSeries
All Implemented Interfaces:
InfiniteSeries<Real>

public class GeometricSeries extends Object implements InfiniteSeries<Real>
Geometric series: Σ ar^n, n=0..∞

A geometric series converges if and only if |r| invalid input: '<' 1. When convergent, the sum is: S = a/(1-r)

Example

// Series: 1 + 1/2 + 1/4 + 1/8 + ... = 2
GeometricSeries series = new GeometricSeries(Real.ONE, Real.of(0.5));
Real sum = series.limit(); // Returns 2.0
Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Constructor Details

    • GeometricSeries

      public GeometricSeries(Real a, Real r)
      Creates a geometric series with first term a and common ratio r.
      Parameters:
      a - the first term
      r - the common ratio
    • GeometricSeries

      public GeometricSeries(double a, double r)
      Convenience constructor with double values.
      Parameters:
      a - the first term
      r - the common ratio
  • Method Details

    • term

      public Real term(int k)
      Description copied from interface: InfiniteSeries
      Returns the k-th term of this series.
      Specified by:
      term in interface InfiniteSeries<Real>
      Parameters:
      k - the term index (k ≥ 0)
      Returns:
      the term a(k)
    • partialSum

      public Real partialSum(int n)
      Description copied from interface: InfiniteSeries
      Computes the partial sum of the first n terms.

      S_n = Σ a(k), k=0..n

      Specified by:
      partialSum in interface InfiniteSeries<Real>
      Parameters:
      n - the number of terms to sum (n ≥ 0)
      Returns:
      the partial sum S_n
    • isConvergent

      public boolean isConvergent()
      Description copied from interface: InfiniteSeries
      Determines if this series is convergent.

      A series converges if lim(n→∞) S_n exists and is finite.

      Specified by:
      isConvergent in interface InfiniteSeries<Real>
      Returns:
      true if convergent, false if divergent
    • limit

      public Real limit()
      Description copied from interface: InfiniteSeries
      Returns the limit of the series if convergent.

      L = lim(n→∞) S_n

      Specified by:
      limit in interface InfiniteSeries<Real>
      Returns:
      the limit L
    • getFirstTerm

      public Real getFirstTerm()
      Returns the first term of this series.
      Returns:
      the first term a
    • getCommonRatio

      public Real getCommonRatio()
      Returns the common ratio of this series.
      Returns:
      the common ratio r
    • toString

      public String toString()
      Overrides:
      toString in class Object