InfiniteSum

com.phasmidsoftware.number.core.misc.InfiniteSum
case class InfiniteSum[X](x0: X, f: (Long, X) => X)(using evidence$1: Numeric[X]) extends Int => X

This case class represents an infinite sum of terms which can be derived by a function (f) which takes as its parameters the index of the term and the previous value of the term.

Type parameters

X

a type for which there is evidence of Numeric[X].

Value parameters

f

the function (see description above).

x0

the initial value of type X which is used for the first term.

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Int => X
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def apply(n: Int): X

The apply function which takes a number n and returns a value of X representing the (finite) sum of the first n terms of the infinite series.

The apply function which takes a number n and returns a value of X representing the (finite) sum of the first n terms of the infinite series.

Value parameters

n

the number which specifies how many terms we should use to evaluate this infinite sum.

Attributes

Returns

an X which represents an approximation to the infinite sum.

def toDouble(n: Int): Double

A function which takes a number n and returns a Double representing the (finite) sum of the first n terms of the infinite series.

A function which takes a number n and returns a Double representing the (finite) sum of the first n terms of the infinite series.

Value parameters

n

the number which specifies how many terms we should use to evaluate this infinite sum.

Attributes

Returns

a Double which represents an approximation to the infinite sum. This values depends on #apply(n).

Inherited methods

def andThen[A](g: X => A): Int => A

Composes two instances of Function1 in a new Function1, with this function applied first.

Composes two instances of Function1 in a new Function1, with this function applied first.

Type parameters

A

the result type of function g

Value parameters

g

a function R => A

Attributes

Returns

a new function f such that f(x) == g(apply(x))

Inherited from:
Function1
def compose[A](g: A => Int): A => X

Composes two instances of Function1 in a new Function1, with this function applied last.

Composes two instances of Function1 in a new Function1, with this function applied last.

Type parameters

A

the type to which function g can be applied

Value parameters

g

a function A => T1

Attributes

Returns

a new function f such that f(x) == apply(g(x))

Inherited from:
Function1
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
override def toString(): String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Function1 -> Any
Inherited from:
Function1

Concrete fields

lazy val asLazyList: LazyList[X]

A lazy val representing the LazyList[X] which is all the terms of the infinite sum.

A lazy val representing the LazyList[X] which is all the terms of the infinite sum.

Attributes