FunctionalEquation

Class which represents functional equations of a certain type. These are formal power series \(g(x)\) that satisfy an equation of the form

\[\sum_{k=1}^m p_k(x) g^{(d_k)} (\lambda_k x) = p(x)\]

for constants \(\lambda_k\), natural numbers \(d_k\) and polynomials \(p_k(x), p(x)\). The generating functions of \(C^2\)-finite sequences satisfy such equations (rec_sequences.C2FiniteSequenceRing.C2FiniteSequence.functional_equation()). The left-hand side of the functional equation is constructed by triples \((d_k, \lambda_k, p_k)\).

EXAMPLES:

sage: from rec_sequences.FunctionalEquation import *

sage: R.<x> = PolynomialRing(QQ)
sage: eq = [(0, -1, 3), (1, 2, x+2)]
sage: print(FunctionalEquation(R, eq, x^2)) 
(3)g(-x) + (x + 2)g'(2x) = x^2

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

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

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

sage: print(a.functional_equation())
(x)g(2x) + (x)g(x) + (1/3)g(3x) = 1/3
class rec_sequences.FunctionalEquation.FunctionalEquation(base, equation, rhs=0, name='g')

Bases: sage.structure.sage_object.SageObject

__init__(base, equation, rhs=0, name='g')

Constructs a functional equation of the form

\[\sum_{k=1}^m p_k(x) g^{(d_k)} (\lambda_k x) = p(x)\]

for constants \(\lambda_k\), natural numbers \(d_k\) and polynomials \(p_k(x), p(x)\)

INPUT:

  • base – the base ring which contains the polynomial coefficients \(p_k,p\) and the constants \(\lambda_k\)

  • equation – a list of triples \((d_k, \lambda_k, p_k)\)

  • rhs – the right-hand side \(p\), a polynomial in base

  • name (default: “g”) – a name which is displayed if the equation is displayed

OUTPUT:

A functional equation of the described form.

EXAMPLES:

sage: from rec_sequences.FunctionalEquation import *

sage: R.<x> = PolynomialRing(QQ)
sage: eq = [(0, -1, 3), (1, 2, x+2)]
sage: print(FunctionalEquation(R, eq, x^2)) 
(3)g(-x) + (x + 2)g'(2x) = x^2
_latex_(name=None)

Creates a latex representation of the functional equation where the derivative of a function \(g(x)\) is denoted by \(g'(x)\) where \(x\) denotes the generator of the base ring.

OUTPUT:

A latex representation of the functional equation.

EXAMPLES:

sage: from rec_sequences.FunctionalEquation import *

sage: R.<x> = PolynomialRing(QQ)
sage: eq = [(2, 2, x+2)]
sage: print(latex(FunctionalEquation(R, eq, 0)))
\left(x + 2\right)g''\left(2x\right) = 0
_repr_(name=None)

Produces a string representation of the equation where the derivative of a function \(g(x)\) is denoted by \(g'(x)\) where \(x\) denotes the generator of the base ring.

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 functional equation.

EXAMPLES:

sage: from rec_sequences.FunctionalEquation import *

sage: R.<x> = PolynomialRing(QQ)
sage: eq = [(0, 1, x), (1, -1, 3), (2, 2, x+2)]
sage: print(FunctionalEquation(R, eq, x^2)) 
(x)g(x) + (3)g'(-x) + (x + 2)g''(2x) = x^2
recurrence(ring)

Creates a recurrence with C-finite coefficients for the coefficient sequence of the function.

Note

Every coefficient sequence of a function satisfying a functional equation of the given type satisfy a linear recurrence with C-finite coefficients. However, not all of those coefficient sequences are \(C^2\)-finite.

INPUT:

OUTPUT:

A list of C-finite sequences \(c_0,\dots,c_r\) such that the coefficient sequence \(a(n)\) of the function satisfies the recurrence \(\sum_{i=0}^r c_i(n) a(n+i)\) for all \(n\).

EXAMPLES:

sage: from rec_sequences.FunctionalEquation import *
sage: from rec_sequences.C2FiniteSequenceRing import *
sage: from rec_sequences.CFiniteSequenceRing import *

sage: R.<x> = PolynomialRing(QQ)
sage: C = CFiniteSequenceRing(QQ)
sage: C2 = C2FiniteSequenceRing(QQ)

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

sage: func_eq = a.functional_equation()
sage: print(func_eq)
(x)g(2x) + (x)g(x) + (1/3)g(3x) = 1/3

sage: func_eq.recurrence(C) == a.coefficients()
True

sage: eq = [(0, 1, x), (1, -1, 3*x), (1, 2, 2)]
sage: func_eq_2 = FunctionalEquation(R, eq, x^2)
sage: func_eq_2.recurrence(C)
[C-finite sequence a(n)=1,
C-finite sequence a(n): (1)*a(n) + (2)*a(n+1) + (1)*a(n+2) = 0 
and a(0)=-3 , a(1)=6,
C-finite sequence a(n): (4)*a(n) + (-4)*a(n+1) + (1)*a(n+2) = 0 
and a(0)=16 , a(1)=48]
sequence(ring, init_values)

Creates a \(C^2\)-finite sequence for the coefficient sequence of the function.

Note

Every coefficient sequence of a function satisfying a functional equation of the given type satisfy a linear recurrence with C-finite coefficients. However, not all of those coefficient sequences are \(C^2\)-finite.

INPUT:

  • ring – a rec_sequences.C2FiniteSequenceRing which contains the coefficients of the recurrences.

  • init_values – initial values used to construct the \(C^2\)-finite sequence.

OUTPUT:

A \(C^2\)-finite sequence representing the coefficient sequence of the function.

EXAMPLES:

sage: from rec_sequences.FunctionalEquation import *
sage: from rec_sequences.C2FiniteSequenceRing import *
sage: from rec_sequences.CFiniteSequenceRing import *

sage: R.<x> = PolynomialRing(QQ)
sage: C = CFiniteSequenceRing(QQ)
sage: C2 = C2FiniteSequenceRing(QQ)

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

sage: func_eq = a.functional_equation()
sage: print(func_eq)
(x)g(2x) + (x)g(x) + (1/3)g(3x) = 1/3

sage: func_eq.sequence(C2, a[:5]) == a
True