Class PowerSeries
java.lang.Object
org.episteme.core.mathematics.analysis.series.PowerSeries
- All Implemented Interfaces:
InfiniteSeries<Real>, InfiniteSequence<Real>, Sequence<Real>
Power series: Σ a_n * x^n, n=0..∞
Power series are fundamental for Taylor and Maclaurin expansions. A power series has a radius of convergence R such that:
- Series converges absolutely for |x| invalid input: '<' R
- Series diverges for |x| > R
- Behavior at |x| = R varies
Common Examples
// e^x = Σ x^n/n!, R = ∞ PowerSeries exp = PowerSeries.exponential(); // sin(x) = Σ (-1)^n * x^(2n+1)/(2n+1)!, R = ∞ PowerSeries sin = PowerSeries.sine(); // 1/(1-x) = Σ x^n, R = 1 PowerSeries geometric = new PowerSeries(n -> Real.ONE);
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Constructor Summary
ConstructorsConstructorDescriptionPowerSeries(Function<Integer, Real> coefficients) Creates a power series with given coefficients evaluated at x = 0 (Maclaurin).Creates a power series with given coefficients evaluated at x. -
Method Summary
Modifier and TypeMethodDescriptionEvaluates the power series at a different point.static PowerSeriescosine()Creates the cosine series: cos(x) = Σ (-1)^n * x^(2n)/(2n)!static PowerSeriesCreates the exponential series: e^x = Σ x^n/n!get(int index) Returns the element at the specified index (0-based).Returns the radius of convergence.static PowerSeriesCreates the hyperbolic cosine series: cosh(x) = Σ x^(2n)/(2n)!static PowerSeriesCreates the hyperbolic sine series: sinh(x) = Σ x^(2n+1)/(2n+1)!static PowerSeriesCreates the arctangent series: atan(x) = Σ (-1)^n * x^(2n+1) / (2n+1)booleanDetermines if this series is convergent.limit()Returns the limit of the series if convergent.static PowerSeriesCreates the natural logarithm series: ln(1+x) = Σ (-1)^(n-1) * x^n / n for n >= 1partialSum(int n) Computes the partial sum of the first n terms.static PowerSeriessine()Creates the sine series: sin(x) = Σ (-1)^n * x^(2n+1)/(2n+1)!static PowerSeriestaylor(DifferentiableFunction<Real, Real> f, Real center) Generates a Taylor series expansion for a differentiable function. f(x) = f(a) + f'(a)(x-a) + f''(a)(x-a)^2/2!static PowerSeriestaylor(DifferentiableFunction<Real, Real> f, Real center, int maxOrder) Generates a Taylor series expansion with memoized derivatives.term(int k) Returns the k-th term of this series.toString()
-
Constructor Details
-
PowerSeries
-
PowerSeries
-
-
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 interfaceInfiniteSequence<Real>- 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 interfaceInfiniteSequence<Real>- Specified by:
limitin interfaceInfiniteSeries<Real>- Returns:
- the limit L
-
getRadiusOfConvergence
-
at
Evaluates the power series at a different point.- Parameters:
newX- new evaluation point- Returns:
- new PowerSeries evaluated at newX
-
exponential
Creates the exponential series: e^x = Σ x^n/n!- Returns:
- exponential power series
-
sine
Creates the sine series: sin(x) = Σ (-1)^n * x^(2n+1)/(2n+1)!- Returns:
- sine power series
-
cosine
Creates the cosine series: cos(x) = Σ (-1)^n * x^(2n)/(2n)!- Returns:
- cosine power series
-
logarithm
Creates the natural logarithm series: ln(1+x) = Σ (-1)^(n-1) * x^n / n for n >= 1- Returns:
- logarithm power series (centered at 0 for ln(1+x))
-
inverseTangent
Creates the arctangent series: atan(x) = Σ (-1)^n * x^(2n+1) / (2n+1)- Returns:
- arctangent power series
-
hyperbolicSine
Creates the hyperbolic sine series: sinh(x) = Σ x^(2n+1)/(2n+1)!- Returns:
- hyperbolic sine power series
-
hyperbolicCosine
Creates the hyperbolic cosine series: cosh(x) = Σ x^(2n)/(2n)!- Returns:
- hyperbolic cosine power series
-
get
-
taylor
Generates a Taylor series expansion for a differentiable function. f(x) = f(a) + f'(a)(x-a) + f''(a)(x-a)^2/2! + ...- Parameters:
f- the differentiable functioncenter- the center point 'a'order- the maximum order of derivative to use (or -1 for infinite if possible, but here we need a limit for practical generation if not symbolic) Actually, PowerSeries takes a function n -> coefficient. If we can compute n-th derivative, we can create the series.- Returns:
- the Taylor series
-
taylor
Generates a Taylor series expansion with memoized derivatives.This overload pre-computes derivatives up to the specified order for better performance when evaluating multiple terms.
f(x) = f(a) + f'(a)(x-a) + f''(a)(x-a)^2/2! + ...- Parameters:
f- the differentiable functioncenter- the center point 'a'maxOrder- the maximum order of derivative to compute- Returns:
- the Taylor series
-
toString
-