FiniteSeries
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
Numerictype-class.
Value parameters
- terms
-
A list of terms that make up the series.
Attributes
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass AbstractSeries[X]trait Series[X]class Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
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
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, orNoneif any term evaluation fails. - Inherited from:
- AbstractSeries
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
Trycontaining the result of the series evaluation if successful, or an exception if the computation fails. - Note
-
Throws java.lang.ClassCastException if
Xis notFuzz[Double]. - Inherited from:
- AbstractSeries
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
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
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
nterms - Inherited from:
- Series
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
Optioncontaining the term at the given index if the index is valid, orNoneotherwise. - Inherited from:
- AbstractSeries
Concrete fields
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.