InfiniteSeries

com.phasmidsoftware.number.core.numerical.InfiniteSeries
case class InfiniteSeries[X](terms: LazyList[X], convergenceRate: Double)(using evidence$1: Numeric[X]) extends AbstractInfiniteSeries[X]

Represents an infinite mathematical series where the terms are lazily evaluated. This class extends the AbstractSeries class and serves as a concrete implementation for series that are infinite in nature.

Type parameters

X

The type of elements in the series, which must have a Numeric type-class instance.

Value parameters

terms

A lazy sequence representing the terms of the infinite series.

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Series[X]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def map[Y : Numeric](f: X => Y): InfiniteSeries[Y]

Transforms the elements of the series using the provided function and returns a new series.

Transforms the elements of the series using the provided function and returns a new series.

Type parameters

Y

The type of the elements in the resulting series, constrained by the Numeric type class.

Value parameters

f

A function that maps each element of type X in the series to a new element of type Y.

Attributes

Returns

A new series where each element is the result of applying the function f to the corresponding element in the original series.

Definition Classes
def nTerms: Option[Int]

Retrieves the number of terms of the series, if defined.

Retrieves the number of terms of the series, if defined.

Attributes

Returns

None.

def unit[Y : Numeric](ys: LazyList[Y]): InfiniteSeries[Y]

Creates a new series from a lazy list of terms, providing a representation of a mathematical series. The terms of the series are derived from the elements of the provided LazyList.

Creates a new series from a lazy list of terms, providing a representation of a mathematical series. The terms of the series are derived from the elements of the provided LazyList.

Value parameters

ys

A LazyList of terms from which the series will be constructed. The terms must be of a numeric type, and a Numeric context bound is required for the type parameter Y.

Attributes

Returns

A Series[Y], representing the mathematical series defined by the input terms.

Inherited methods

def evaluate(maybeN: Option[Int] = ...): Option[X]

Evaluates the series by summing the specified number of terms or a default number of terms if not provided. If any term cannot be evaluated, the method returns None.

Evaluates the series by summing the specified number of terms or a default number of terms if not provided. If any term cannot be evaluated, the method returns None.

Value parameters

maybeN

An optional integer specifying the number of terms to evaluate. If not provided, the default number of terms will be used.

Attributes

Returns

An Option[X] containing the result of the summation if all terms are successfully evaluated, or None if any term evaluation fails.

Inherited from:
AbstractInfiniteSeries
def evaluateToTolerance(epsilon: Double): Try[X]

Evaluates the series by summing the terms until their absolute value falls below a given threshold. NOTE: the result of this method is always a Try[Number], regardless of X. If X and Number are not the same, a ClassCastException will be thrown.

Evaluates the series by summing the terms until their absolute value falls below a given threshold. NOTE: the result of this method is always a Try[Number], regardless of X. If X and Number are not the same, a ClassCastException will be thrown.

Value parameters

epsilon

The threshold value for determining the cutoff in the series evaluation. Terms with an absolute value less than this will not be included.

Attributes

Returns

A Try containing the result of the series evaluation if successful, or an exception if the computation fails.

Note

Throws java.lang.ClassCastException if X is not Fuzz[Double].

Inherited from:
AbstractInfiniteSeries
def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
def render(n: Int): String

Generates a string representation of the series, including up to a specified number of terms. The output is formatted as "Series: (n terms) x1, x2, ..., xn,".

Generates a string representation of the series, including up to a specified number of terms. The output is formatted as "Series: (n terms) x1, x2, ..., xn,".

Value parameters

n

the number of terms to include in the rendered representation of the series

Attributes

Returns

a string that represents the series with up to n terms

Inherited from:
Series
def term(i: Int): Option[X]

Retrieves the term at the specified index from the series, if the index is valid.

Retrieves the term at the specified index from the series, if the index is valid.

A valid index is non-negative and less than the total number of terms in the series, as defined by nTerms.

Value parameters

i

The index of the term to retrieve.

Attributes

Returns

An Option containing the term at the given index if the index is valid, or None otherwise.

Inherited from:
AbstractInfiniteSeries