# Constant-recursive sequence

In mathematics, a constant-recursive sequence or C-finite sequence is a sequence satisfying a linear recurrence with constant coefficients.

## Definition

An order-d homogeneous linear recurrence with constant coefficients is an equation of the form

$s(n)=c_{1}s(n-1)+c_{2}s(n-2)+\dots +c_{d}s(n-d),$ where the d coefficients $c_{1},c_{2},\dots ,c_{d}$ are constants.

A sequence $s(0),s(1),s(2),\dots$ is a constant-recursive sequence if there is an order-d homogeneous linear recurrence with constant coefficients that it satisfies for all $n\geq d$ .

Equivalently, $s(n)_{n\geq 0}$ is constant-recursive if the set of sequences

$\{s(n+r)_{n\geq 0}:r\geq 0\}$ is contained in a vector space whose dimension is finite.

## Examples

### Fibonacci sequence

The sequence 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... of Fibonacci numbers satisfies the recurrence

$F_{n}=F_{n-1}+F_{n-2}$ $F_{0}=0$ $F_{1}=1.$ Explicitly, the recurrence yields the values

$F_{2}=F_{1}+F_{0}=1$ $F_{3}=F_{2}+F_{1}=2$ $F_{4}=F_{3}+F_{2}=3$ $F_{5}=F_{4}+F_{3}=5$ etc.

### Lucas sequences

The sequence 2, 1, 3, 4, 7, 11, 18, 29, 47, 76, 123, 199, ... (sequence A000032 in the OEIS) of Lucas numbers satisfies the same recurrence as the Fibonacci sequence but with initial conditions

$L_{0}=2$ $L_{1}=1.$ More generally, every Lucas sequence is a constant-recursive sequence.

### Geometric sequences

The geometric sequence $a,ar,ar^{2},\dots$ is constant-recursive, since it satisfies the recurrence $s(n)=rs(n-1)$ for all $n\geq 1$ .

### Eventually periodic sequences

A sequence that is eventually periodic with period length $\ell$ is constant-recursive, since it satisfies $s(n)=s(n-\ell )$ for all $n\geq d$ for some $d$ .

### Polynomial sequences

For any polynomial s(n), the sequence of its values is a constant-recursive sequence. If the degree of the polynomial is d, the sequence satisfies a recurrence of order $d+1$ , with coefficients given by the corresponding element of the binomial transform. The first few such equations are

$s(n)=1\cdot s(n-1)$ for a degree 0 (that is, constant) polynomial,
$s(n)=2\cdot s(n-1)-1\cdot s(n-2)$ for a degree 1 or less polynomial,
$s(n)=3\cdot s(n-1)-3\cdot s(n-2)+1\cdot s(n-3)$ for a degree 2 or less polynomial, and
$s(n)=4\cdot s(n-1)-6\cdot s(n-2)+4\cdot s(n-3)-1\cdot s(n-4)$ for a degree 3 or less polynomial.

A sequence obeying the order-d equation also obeys all higher order equations. These identities may be proved in a number of ways, including via the theory of finite differences. Each individual equation may also be verified by substituting the degree-d polynomial

$s(x)=\sum _{k=0}^{d}a_{k}x^{k},$ where the coefficients $a_{k}$ are symbolic. Any sequence of $d+1$ integer, real, or complex values can be used as initial conditions for a constant-recursive sequence of order $d+1$ . If the initial conditions lie on a polynomial of degree $d-1$ or less, then the constant-recursive sequence also obeys a lower order equation.

### Enumeration of words in a regular language

Let $L$ be a regular language, and let $s(n)$ be the number of words of length $n$ in $L$ . Then $s(n)_{n\geq 0}$ is constant-recursive.

## Characterization in terms of exponential polynomials

The characteristic polynomial (or "auxiliary polynomial") of the recurrence is the polynomial

$x^{d}-c_{1}x^{d-1}-\dots -c_{d-1}x-c_{d}$ whose coefficients are the same as those of the recurrence. The nth term $s(n)$ of a constant-recursive sequence can be written in terms of the roots of its characteristic polynomial. If the d roots $r_{1},r_{2},\dots ,r_{d}$ are all distinct, then the nth term of the sequence is

$s(n)=k_{1}r_{1}^{n}+k_{2}r_{2}^{n}+\dots +k_{d}r_{d}^{n}$ where the coefficients ki are constants that can be determined from the initial conditions.

For the Fibonacci sequence, the characteristic polynomial is $x^{2}-x-1$ , whose roots $\phi ={\frac {1+{\sqrt {5}}}{2}}$ and ${\bar {\phi }}={\frac {1-{\sqrt {5}}}{2}}$ appear in Binet's formula

$F_{n}={\frac {\phi ^{n}-{\bar {\phi }}^{n}}{\sqrt {5}}}.$ More generally, if a root r of the characteristic polynomial has multiplicity m, then the term $r^{n}$ is multiplied by a degree-$(m-1)$ polynomial in n. That is, let $r_{1},\dots ,r_{e}$ be the distinct roots of the characteristic polynomial. Then

$s(n)=k_{1}(n)r_{1}^{n}+k_{2}(n)r_{2}^{n}+\dots +k_{e}(n)r_{e}^{n}$ where $k_{i}(n)$ is a polynomial of degree $m_{i}-1$ . For instance, if the characteristic polynomial factors as $(x-r)^{3}$ , with the same root r occurring three times, then the nth term is of the form

$s(n)=(a+bn+cn^{2})r^{n}.$ Conversely, if there are polynomials $k_{i}(n)$ such that

$s(n)=k_{1}(n)r_{1}^{n}+k_{2}(n)r_{2}^{n}+\dots +k_{e}(n)r_{e}^{n},$ then $s(n)_{n\geq 0}$ is constant-recursive.

## Characterization in terms of rational generating functions

A sequence is constant-recursive precisely when its generating function

$\sum _{n\geq 0}s(n)x^{n}=s(0)+s(1)x^{1}+s(2)x^{2}+s(3)x^{3}+\cdots$ is a rational function. The denominator is the polynomial obtained from the auxiliary polynomial by reversing the order of the coefficients, and the numerator is determined by the initial values of the sequence.

The generating function of the Fibonacci sequence is

${\frac {x}{1-x-x^{2}}}.$ In general, multiplying a generating function by the polynomial

$1-c_{1}x^{1}-c_{2}x^{2}-\dots -c_{d}x^{d}$ yields a series

$\left(s(0)+s(1)x^{1}+s(2)x^{2}+\cdots \right)\left(1-c_{1}x^{1}-c_{2}x^{2}-\dots -c_{d}x^{d}\right)=\left(b_{0}+b_{1}x^{1}+b_{2}x^{2}+\cdots \right),$ where

$b_{n}=s(n)-c_{1}s(n-1)-c_{2}s(n-2)-\dots -c_{d}s(n-d).$ If $s(n)$ satisfies the recurrence relation

$s(n)=c_{1}s(n-1)+c_{2}s(n-2)+\dots +c_{d}s(n-d),$ then $b_{n}=0$ for all $n\geq d$ . In other words,

$\left(s(0)+s(1)x^{1}+s(2)x^{2}+\cdots \right)\left(1-c_{1}x^{1}-c_{2}x^{2}-\dots -c_{d}x^{d}\right)=\left(b_{0}+b_{1}x^{1}+b_{2}x^{2}+\dots +b_{d-1}x^{d-1}\right),$ so we obtain the rational function

$\sum _{n\geq 0}s(n)x^{n}={\frac {b_{0}+b_{1}x^{1}+b_{2}x^{2}+\dots +b_{d-1}x^{d-1}}{1-c_{1}x^{1}-c_{2}x^{2}-\dots -c_{d}x^{d}}}.$ In the special case of a periodic sequence satisfying $s(n)=s(n-d)$ for $n\geq d$ , the generating function is

{\begin{aligned}{\frac {s(0)+s(1)x^{1}+\dots +s(d-1)x^{d-1}}{1-x^{d}}}=&\left(s(0)+s(1)x^{1}+\dots +s(d-1)x^{d-1}\right)+\left(s(0)+s(1)x^{1}+\dots +s(d-1)x^{d-1}\right)x^{d}+{}\\&\left(s(0)+s(1)x^{1}+\dots +s(d-1)x^{d-1}\right)x^{2d}+\cdots \end{aligned}} by expanding the geometric series.

The generating function of the Catalan numbers is not a rational function, which implies that the Catalan numbers do not satisfy a linear recurrence with constant coefficients.

## Closure properties

The termwise addition or multiplication of two constant-recursive sequences is again constant-recursive. This follows from the characterization in terms of exponential polynomials.

The Cauchy product of two constant-recursive sequences is constant-recursive. This follows from the characterization in terms of rational generating functions.

## Sequences satisfying non-homogeneous recurrences

A sequence satisfying a non-homogeneous linear recurrence with constant coefficients is constant-recursive.

This is because the recurrence

$s(n)=c_{1}s(n-1)+c_{2}s(n-2)+\dots +c_{d}s(n-d)+c$ can be solved for $c$ to obtain

$c=s(n)-c_{1}s(n-1)-c_{2}s(n-2)-\dots -c_{d}s(n-d).$ Substituting this into the equation

$s(n+1)=c_{1}s(n)+c_{2}s(n-1)+\dots +c_{d}s(n+1-d)+c$ shows that $s(n)$ satisfies the homogeneous recurrence

$s(n+1)=(c_{1}+1)s(n)+(c_{2}-c_{1})s(n-1)+\dots +(c_{d}-c_{d-1})s(n+1-d)-c_{d}s(n-d)$ of order $d+1$ .

## Generalizations

A natural generalization is obtained by relaxing the condition that the coefficients of the recurrence are constants. If the coefficients are allowed to be polynomials, then one obtains holonomic sequences.

A $k$ -regular sequence satisfies linear recurrences with constant coefficients, but the recurrences take a different form. Rather than $s(n)$ being a linear combination of $s(m)$ for some integers $m$ that are close to $n$ , each term $s(n)$ in a $k$ -regular sequence is a linear combination of $s(m)$ for some integers $m$ whose base-$k$ representations are close to that of $n$ . Constant-recursive sequences can be thought of as $1$ -regular sequences, where the base-1 representation of $n$ consists of $n$ copies of the digit $1$ .