_Sequence

it.grypho.scala.leonardo.scalar._Sequence
case class _Sequence(kind: SeqKind, n: _Expression, seeds: List[_Expression]) extends _Expression

A term of a linear recurrence: fib(n), lucas(n), pell(n), jacobsthal(n), and the seed-generalised fib(n, a, b).

Indexing is the standard one: x(0) = 0, x(1) = 1, so fib(10) = 55, matching OEIS A000045 and every published table. The "classic rabbit" pair is fib(n, 1, 1), which is this sequence shifted by one (fib(n, 1, 1) = fib(n+1)). Stated here because it cannot be inferred and an off-by-one would be silent — the rule also applied to the spherical polar angle.

These are numeric sequences, not integer ones. The recurrence needs only addition and multiplication, so fib(5, 1.5, -pi) is a legitimate call and exact seeds stay exact. An exact integer index with exact seeds goes through linRecExact, which is what lets fib(79) be right: F(79) exceeds 2^53, so the Double path can only approximate it.

Value parameters

kind

which recurrence

n

the index

seeds

empty for the kind's own seeds, or exactly two expressions overriding them

Attributes

Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait _Expression
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def children: List[_Expression]

Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.

Sub-expressions subject to recursive structural traversal. Binder positions (e.g. the differentiation variable) are excluded.

Attributes

Definition Classes
override def eval(env: Environment): Either[_Expression, _Value]

Reduces this expression in the given environment.

Reduces this expression in the given environment.

Value parameters

env

variable bindings and display precision

Attributes

Returns

Right(v) when all free variables resolved to concrete values; Left(e) when reduction is partial or impossible

Definition Classes
override def rebuild(c: List[_Expression]): _Expression

Reconstructs the same node shape with replacement sub-expressions.

Reconstructs the same node shape with replacement sub-expressions.

Value parameters

newChildren

replacements in the same order and count as children

Attributes

Definition Classes
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
Any

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product

Inherited fields

lazy val freeVars: Set[String]

Cached set of free variable names; O(1) after the first access.

Cached set of free variable names; O(1) after the first access.

Attributes

Inherited from:
_Expression