C2FiniteSequenceBounded and C2FiniteSequenceRingBounded

class rec_sequences.C2FiniteSequenceRingBounded.C2FiniteSequenceBounded(parent, coefficients, initial_values, name='a', is_gen=False, construct=False, cache=True, *args, **kwds)

Bases: rec_sequences.DifferenceDefinableSequenceRing.DifferenceDefinableSequence

A C^2-finite sequence, i.e. a sequence where every term can be determined by a linear recurrence with coefficients coming from a C-finite sequence ring and finitely many initial values. We assume that this recurrence holds for all values and that the leading coefficient only contains finitely many zeros (which is not checked).

__init__(parent, coefficients, initial_values, name='a', is_gen=False, construct=False, cache=True, *args, **kwds)

Construct a \(C^2\)-finite sequence \(a(n)\) with recurrence

\[c_0(n) a(n) + \dots + c_r(n) a(n+r) = 0 \text{ for all } n \geq 0\]

from given list of coefficients \(c_0, ... , c_r\) and given list of initial values \(a(0), ..., a(r-1)\).

Note

We assume that the leading coefficient \(c_r\) only contains finitely many zero terms and enough initial values are given such that the sequence can be uniquely continued.

INPUT:

  • parent – a C2FiniteSequenceRingBounded

  • coefficients – the coefficients of the recurrence

  • initial_values – a list of initial values, determining the sequence with at least order of the recurrence many values

  • name (default “a”) – a name for the sequence

OUTPUT:

A sequence determined by the given recurrence and initial values.

EXAMPLES:

sage: from rec_sequences.C2FiniteSequenceRingBounded import *
sage: from rec_sequences.CFiniteSequenceRing import *

sage: C = CFiniteSequenceRing(QQ)
sage: C2 = C2FiniteSequenceRingBounded(QQ)

sage: n = var("n")
sage: c = C(2^n+1)
sage: a = C2([c, -1], [3])
sage: a
C^2-finite sequence of order 1 and degree 2 with coefficients:
> c0 (n) : C-finite sequence c0(n): (2)*c0(n) + (-3)*c0(n+1) + (1)*c0(n+2) = 0 and c0(0)=2 , c0(1)=3
> c1 (n) : C-finite sequence c1(n)=-1
and initial values a(0)=3
_latex_(name=None)

Creates a latex representation of the sequence. This is done by creating the latex representation of the closed forms of the coefficients and showing the recurrence and the initial values.

OUTPUT:

A latex representation showing the closed form of the sequence.

EXAMPLES:

sage: from rec_sequences.C2FiniteSequenceRingBounded import *
sage: from rec_sequences.CFiniteSequenceRing import *

sage: C = CFiniteSequenceRing(QQ)
sage: C2 = C2FiniteSequenceRingBounded(QQ)

sage: n = var("n")
sage: c = C(2^n+1)
sage: d = C(3^n)
sage: a = C2([c, d], [1])

sage: print(latex(a))
\left(2^{n} + 1\right)\cdot a(n) + \left(3^{n}\right) \cdot a(n+1) = 0 \quad a(0)=1
_repr_(name=None)

Produces a string representation of the sequence.

INPUT:

  • name (optional) – a string used as the name of the sequence; if not given, self.name() is used.

OUTPUT:

A string representation of the sequence consisting of the recurrence and enough initial values to uniquely define the sequence.

EXAMPLES:

sage: from rec_sequences.C2FiniteSequenceRingBounded import *
sage: from rec_sequences.CFiniteSequenceRing import *

sage: C = CFiniteSequenceRing(QQ)
sage: C2 = C2FiniteSequenceRingBounded(QQ)

sage: n = var("n")
sage: c = C(2^n)
sage: a = C2([c, -1], [1])
sage: a
C^2-finite sequence of order 1 and degree 1 with coefficients:
> c0 (n) : C-finite sequence c0(n): (2)*c0(n) + (-1)*c0(n+1) = 0 and c0(0)=1
> c1 (n) : C-finite sequence c1(n)=-1
and initial values a(0)=1  
eigenvalues()

Returns a list of the eigenvalues that appear in the coefficients of the defining recurrence.

OUTPUT:

A list of the pairwise distinct eigenvalues of the coefficients.

EXAMPLES:

sage: from rec_sequences.C2FiniteSequenceRingBounded import *

sage: C = CFiniteSequenceRing(QQ)
sage: C2 = C2FiniteSequenceRingBounded(QQ)

sage: var("n");
n
sage: c = C(2^n+3^n)
sage: d = C((-1)^n)
sage: e = C(1)

sage: sorted(C2([c,d*c,d,c,e], [1,2,3,5]).eigenvalues())
[-3, -2, -1, 1, 2, 3]
log = <Logger C2FinBound (WARNING)>
subsequence(u, v=0, check_torsion_number=True, *args, **kwargs)

Returns the sequence \(c(n u + v)\).

INPUT:

  • u – a natural number

  • v (default: 0) – a natural number

OUTPUT:

The sequence \(c(n u + v)\).

torsion_number(*others)

Compute the torsion number of some C^2-finite sequences.

INPUT:

  • others – C^2-finite sequences

OUTPUT:

The torsion number of self and the other given C^2-finite sequences.

EXAMPLES:

sage: from rec_sequences.C2FiniteSequenceRingBounded import *

sage: C = CFiniteSequenceRing(QQ)
sage: C2 = C2FiniteSequenceRingBounded(QQ)

sage: alt = C(10*[1,-1])
sage: C2([alt, 1], [1]).torsion_number()
2
class rec_sequences.C2FiniteSequenceRingBounded.C2FiniteSequenceRingBounded(base_ring, name=None, element_class=None, category=None, *args, **kwds)

Bases: rec_sequences.DifferenceDefinableSequenceRing.DifferenceDefinableSequenceRing

A Ring of C^2-finite sequences where the orders for closure properties are bounded.

Element

alias of rec_sequences.C2FiniteSequenceRingBounded.C2FiniteSequenceBounded

__init__(base_ring, name=None, element_class=None, category=None, *args, **kwds)

Constructor for a \(C^2\)-finite sequence ring.

INPUT:

  • field (default: QQ) – a field of characteristic zero over which the \(C^2\)-finite sequence ring is defined.

OUTPUT:

A ring of \(C^2\)-finite sequences

EXAMPLES:

sage: from rec_sequences.C2FiniteSequenceRingBounded import *
sage: C2FiniteSequenceRingBounded(QQ)
Ring of bounded C^2-finite sequences with base field Rational Field
_element_constructor_(x, y=None, name='a', check=True, is_gen=False, construct=False, *args, **kwds)

Tries to construct a sequence \(a(n)\).

This is possible if:

  • x is already a bounded \(C^2\)-finite sequence.

  • x is a list of C-finite sequences and y is a list of field elements. Then x is interpreted as the coefficients of the recurrence and y as the initial values of the sequence, i.e. \(a(0), ..., a(r-1)\).

  • x is a C-finite sequence.

  • x can be converted into a field element. Then it is interpreted as the constant sequence \((x)_{n \in \mathbb{N}}\)

EXAMPLES:

sage: from rec_sequences.C2FiniteSequenceRingBounded import *
sage: from rec_sequences.CFiniteSequenceRing import *

sage: C = CFiniteSequenceRing(QQ)
sage: C2 = C2FiniteSequenceRingBounded(QQ) 
sage: n = var("n")

sage: c = C(2^n+(-1)^n)
sage: d = C(2^n+1)
sage: a = C2([c,-d], [1], name="a")
sage: print(latex(a))
\left(2^{n} + \left(-1\right)^{n}\right)\cdot a(n) + \left(-2^{n} - 
1\right) \cdot a(n+1) = 0 \quad a(0)=1
sage: a2 = C2(a)

sage: b = C2(c)
sage: print(b)
C^2-finite sequence of order 2 and degree 1 with coefficients:
> c0 (n) : C-finite sequence c0(n)=2
> c1 (n) : C-finite sequence c1(n)=1
> c2 (n) : C-finite sequence c2(n)=-1
and initial values a(0)=2 , a(1)=1
_latex_()

OUTPUT:

A latex representation of the sequence ring.

EXAMPLES:

sage: from rec_sequences.C2FiniteSequenceRingBounded import *
sage: print(latex(C2FiniteSequenceRingBounded(QQ)))
\mathcal{C^2}(\Bold{Q})
_repr_()

OUTPUT:

A string representation of the sequence ring.

EXAMPLES:

sage: from rec_sequences.C2FiniteSequenceRingBounded import *
sage: C2FiniteSequenceRingBounded(QQ)
Ring of bounded C^2-finite sequences with base field Rational Field
log = <Logger C2FinRingBound (WARNING)>