Class PowerSeries

java.lang.Object
org.episteme.core.mathematics.analysis.series.PowerSeries
All Implemented Interfaces:
InfiniteSeries<Real>, InfiniteSequence<Real>, Sequence<Real>

public class PowerSeries extends Object implements InfiniteSeries<Real>, InfiniteSequence<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 Details

    • PowerSeries

      public PowerSeries(Function<Integer,Real> coefficients, Real x, Real radiusOfConvergence)
      Creates a power series with given coefficients evaluated at x.
      Parameters:
      coefficients - function mapping n to a_n
      x - point of evaluation
      radiusOfConvergence - radius of convergence R
    • PowerSeries

      public PowerSeries(Function<Integer,Real> coefficients)
      Creates a power series with given coefficients evaluated at x = 0 (Maclaurin).
      Parameters:
      coefficients - function mapping n to a_n
  • 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 InfiniteSequence<Real>
      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 InfiniteSequence<Real>
      Specified by:
      limit in interface InfiniteSeries<Real>
      Returns:
      the limit L
    • getRadiusOfConvergence

      public Real getRadiusOfConvergence()
      Returns the radius of convergence.
      Returns:
      R
    • at

      public PowerSeries at(Real newX)
      Evaluates the power series at a different point.
      Parameters:
      newX - new evaluation point
      Returns:
      new PowerSeries evaluated at newX
    • exponential

      public static PowerSeries exponential()
      Creates the exponential series: e^x = Σ x^n/n!
      Returns:
      exponential power series
    • sine

      public static PowerSeries sine()
      Creates the sine series: sin(x) = Σ (-1)^n * x^(2n+1)/(2n+1)!
      Returns:
      sine power series
    • cosine

      public static PowerSeries cosine()
      Creates the cosine series: cos(x) = Σ (-1)^n * x^(2n)/(2n)!
      Returns:
      cosine power series
    • logarithm

      public static PowerSeries 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

      public static PowerSeries inverseTangent()
      Creates the arctangent series: atan(x) = Σ (-1)^n * x^(2n+1) / (2n+1)
      Returns:
      arctangent power series
    • hyperbolicSine

      public static PowerSeries hyperbolicSine()
      Creates the hyperbolic sine series: sinh(x) = Σ x^(2n+1)/(2n+1)!
      Returns:
      hyperbolic sine power series
    • hyperbolicCosine

      public static PowerSeries hyperbolicCosine()
      Creates the hyperbolic cosine series: cosh(x) = Σ x^(2n)/(2n)!
      Returns:
      hyperbolic cosine power series
    • get

      public Real get(int index)
      Description copied from interface: Sequence
      Returns the element at the specified index (0-based).
      Specified by:
      get in interface Sequence<Real>
      Parameters:
      index - the index of the element to retrieve
      Returns:
      the element at the specified index
    • taylor

      public static PowerSeries taylor(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! + ...
      Parameters:
      f - the differentiable function
      center - 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

      public static PowerSeries taylor(DifferentiableFunction<Real,Real> f, Real center, int maxOrder)
      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 function
      center - the center point 'a'
      maxOrder - the maximum order of derivative to compute
      Returns:
      the Taylor series
    • toString

      public String toString()
      Overrides:
      toString in class Object