Class GeometricSeries
java.lang.Object
org.episteme.core.mathematics.analysis.series.GeometricSeries
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionGeometricSeries(double a, double r) Convenience constructor with double values.GeometricSeries(Real a, Real r) Creates a geometric series with first term a and common ratio r. -
Method Summary
Modifier and TypeMethodDescriptionReturns the common ratio of this series.Returns the first term of this series.booleanDetermines if this series is convergent.limit()Returns the limit of the series if convergent.partialSum(int n) Computes the partial sum of the first n terms.term(int k) Returns the k-th term of this series.toString()
-
Constructor Details
-
GeometricSeries
-
GeometricSeries
public GeometricSeries(double a, double r) Convenience constructor with double values.- Parameters:
a- the first termr- the common ratio
-
-
Method Details
-
term
Description copied from interface:InfiniteSeriesReturns the k-th term of this series.- Specified by:
termin interfaceInfiniteSeries<Real>- Parameters:
k- the term index (k ≥ 0)- Returns:
- the term a(k)
-
partialSum
Description copied from interface:InfiniteSeriesComputes the partial sum of the first n terms.S_n = Σ a(k), k=0..n
- Specified by:
partialSumin interfaceInfiniteSeries<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:InfiniteSeriesDetermines if this series is convergent.A series converges if lim(n→∞) S_n exists and is finite.
- Specified by:
isConvergentin interfaceInfiniteSeries<Real>- Returns:
- true if convergent, false if divergent
-
limit
Description copied from interface:InfiniteSeriesReturns the limit of the series if convergent.L = lim(n→∞) S_n
- Specified by:
limitin interfaceInfiniteSeries<Real>- Returns:
- the limit L
-
getFirstTerm
-
getCommonRatio
-
toString
-