FiniteSeries

com.phasmidsoftware.number.core.numerical.FiniteSeries
case class FiniteSeries[X](terms: Seq[X])(using evidence$1: Numeric[X]) extends AbstractSeries[X]

Represents a finite mathematical series with a fixed number of terms.

This case class models a series consisting of a finite number of terms, which are stored in a list. Each term in the series is of type X, constrained by an implicit Numeric type-class for numerical operations.

Type parameters

X

The type of the elements (terms) in the series, which must have an associated Numeric type-class.

Value parameters

terms

A list of terms that make up the series.

Attributes

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

Members list

Value members

Concrete methods

def nTerms: Option[Int]

Calculates the number of terms in the series.

Calculates the number of terms in the series.

This method returns the count of terms in the finite series as an optional integer. If the series is empty, the result will still be wrapped in Some, indicating a count of 0.

Attributes

Returns

An Option[Int] representing the number of terms in the series.

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.

CONSIDER merge with the other implementation of this

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:
AbstractSeries
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:
AbstractSeries
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:
AbstractSeries

Concrete fields

lazy val convergenceRate: Double

Returns the default convergence rate used for evaluating the series. The convergence rate determines the threshold at which terms in the series are considered sufficiently small to be ignored in the evaluation. This is used to determine the error bounds when evaluating to a tolerance. The error bounds are the tolerance divided by this number

Returns the default convergence rate used for evaluating the series. The convergence rate determines the threshold at which terms in the series are considered sufficiently small to be ignored in the evaluation. This is used to determine the error bounds when evaluating to a tolerance. The error bounds are the tolerance divided by this number

Attributes

Returns

The convergence rate as a Double.