# P-recursive equation

In mathematics a P-recursive equation is a linear equation of sequences where the coefficient sequences can be represented as polynomials. P-recursive equations are linear recurrence equations (or linear recurrence relations or linear difference equations) with polynomial coefficients. These equations play an important role in different areas of mathematics, specifically in combinatorics. The sequences which are solutions of these equations are called holonomic, P-recursive or D-finite.
From the late 1980s, the first algorithms were developed to find solutions for these equations. Sergei A. Abramov, Marko Petkovšek and Mark van Hoeij described algorithms to find polynomial, rational, hypergeometric and d'Alembertian solutions.

## Definition

Let K{\textstyle \mathbb {K} } be a field of characteristic zero (for example K=Q{\textstyle \mathbb {K} =\mathbb {Q} }), p$_k$(n)∈K[n]{\textstyle p_{k}(n)\in \mathbb {K} [n]} polynomials for k=0, …, r{\textstyle k=0, \dots , r}, f∈K$^N${\textstyle f\in \mathbb {K} ^{\mathbb {N} }} a sequence and y∈K$^N${\textstyle y\in \mathbb {K} ^{\mathbb {N} }} an unknown sequence. The equation$\sum _{k=0}^{r}p_{k}(n)\,y(n+k)=f(n)$is called a linear recurrence equation with polynomial coefficients (all recurrence equations in this article are of this form). If p$_0${\textstyle p_{0}} and p$_r${\textstyle p_{r}} are both nonzero, then r{\textstyle r} is called the order of the equation. If f{\textstyle f} is zero the equation is called homogeneous, otherwise it is called inhomogeneous.
This can also be written as Ly=f{\textstyle Ly=f} where L=∑$_{k=0}$$^r$p$_k$N$^k${\textstyle L=\sum _{k=0}^{r}p_{k}N^{k}} is a linear recurrence operator with polynomial coefficients and N{\textstyle N} is the shift operator, i.e. Ny(n)=y(n+1){\textstyle N\, y(n)=y(n+1)}.

## Closed form solutions

Let ∑$_{k=0}$$^r$p$_k$(n)y(n+k)=f(n){\textstyle \sum _{k=0}^{r}p_{k}(n)\, y(n+k)=f(n)} or equivalently Ly=f{\textstyle Ly=f} be a recurrence equation with polynomial coefficients. There exist several algorithms which compute solutions of this equation. These algorithms can compute polynomial, rational, hypergeometric and d'Alembertian solutions. The solution of a homogeneous equation is given by the kernel of the linear recurrence operator: ker⁡L={y∈K$^N$:Ly=0}{\textstyle \ker L=\{y\in \mathbb {K} ^{\mathbb {N} }\, :\, Ly=0\}}. As a subspace of the space of sequences this kernel has a basis. Let {y$^{(1)}$, y$^{(2)}$, …, y$^{(m)}$}{\textstyle \{y^{(1)}, y^{(2)}, \dots , y^{(m)}\}} be a basis of ker⁡L{\textstyle \ker L}, then the formal sum c$_1$y$^{(1)}$+⋯+c$_m$y$^{(m)}${\textstyle c_{1}y^{(1)}+\dots +c_{m}y^{(m)}} for arbitrary constants c$_1$, …, c$_m$∈K{\textstyle c_{1}, \dots , c_{m}\in \mathbb {K} } is called the general solution of the homogeneous problem Ly=0{\textstyle Ly=0}. If y$^~${\textstyle {\tilde {y}}} is a particular solution of Ly=f{\textstyle Ly=f}, i.e. Ly$^~$=f{\textstyle L{\tilde {y}}=f}, then c$_1$y$^{(1)}$+⋯+c$_m$y$^{(m)}$+y$^~${\textstyle c_{1}y^{(1)}+\dots +c_{m}y^{(m)}+{\tilde {y}}} is also a solution of the inhomogeneous problem and it is called the general solution of the inhomogeneous problem.

### Polynomial solutions

In the late 1980s Sergei A. Abramov described an algorithm which finds the general polynomial solution of a recurrence equation, i.e. y(n)∈K[n]{\textstyle y(n)\in \mathbb {K} [n]}, with a polynomial right-hand side f(n)∈K[n]{\textstyle f(n)\in \mathbb {K} [n]}. He (and a few years later Marko Petkovšek) gave a degree bound for polynomial solutions. This way the problem can simply be solved by considering a system of linear equations. In 1995 Abramov, Bronstein and Petkovšek showed that the polynomial case can be solved more efficiently by considering power series solution of the recurrence equation in a specific power basis (i.e. not the ordinary basis (x$^n$)$_{n∈N}${\textstyle (x^{n})_{n\in \mathbb {N} }}).
The other algorithms for finding more general solutions (e.g. rational or hypergeometric solutions) also rely on algorithms which compute polynomial solutions.

### Rational solutions

In 1989 Sergei A. Abramov showed that a general rational solution, i.e. y(n)∈K(n){\textstyle y(n)\in \mathbb {K} (n)}, with polynomial right-hand side f(n)∈K[n]{\textstyle f(n)\in \mathbb {K} [n]}, can be found by using the notion of a universal denominator. A universal denominator is a polynomial u{\textstyle u} such that the denominator of every rational solution divides u{\textstyle u}. Abramov showed how this universal denominator can be computed by only using the first and the last coefficient polynomial p$_0${\textstyle p_{0}} and p$_r${\textstyle p_{r}}. Substituting this universal denominator for the unknown denominator of $y$ all rational solutions can be found by computing all polynomial solutions of a transformed equation.

### Hypergeometric solution

A sequence y(n){\textstyle y(n)} is called hypergeometric if the ratio of two consecutive terms is a rational function in $n$, i.e. y(n+1)/y(n)∈K(n){\textstyle y(n+1)/y(n)\in \mathbb {K} (n)}. This is the case if and only if the sequence is the solution of a first-order recurrence equation with polynomial coefficients. The set of hypergeometric sequences is not a subspace of the space of sequences as it is not closed under addition.
In 1992 Marko Petkovšek gave an algorithm to get the general hypergeometric solution of a recurrence equation where the right-hand side $f$ is the sum of hypergeometric sequences. The algorithm makes use of the Gosper-Petkovšek normal-form of a rational function. With this specific representation it is again sufficient to consider polynomial solutions of a transformed equation.
A different and more efficient approach is due to Mark van Hoeij. Considering the roots of the first and the last coefficient polynomial p$_0${\textstyle p_{0}} and p$_r${\textstyle p_{r}} – called singularities – one can build a solution step by step making use of the fact that every hypergeometric sequence y(n){\textstyle y(n)} has a representation of the form$y(n)=c\,r(n)\,z^{n}\,\Gamma (n-\xi _{1})^{e_{1}}\Gamma (n-\xi _{2})^{e_{2}}\cdots \Gamma (n-\xi _{s})^{e_{s}}$for some c∈K, z∈K$^¯$, s∈N, r(n)∈K$^¯$(n), ξ$_1$, …, ξ$_s$∈K$^¯${\textstyle c\in \mathbb {K} , z\in {\overline {\mathbb {K} }}, s\in \mathbb {N} , r(n)\in {\overline {\mathbb {K} }}(n), \xi _{1}, \dots , \xi _{s}\in {\overline {\mathbb {K} }}} with ξ$_i$−ξ$_j$∉Z{\textstyle \xi _{i}-\xi _{j}\notin \mathbb {Z} } for i≠j{\textstyle i\neq j} and e$_1$, …, e$_s$∈Z{\textstyle e_{1}, \dots , e_{s}\in \mathbb {Z} }. Here Γ(n){\textstyle \Gamma (n)} denotes the Gamma function and K$^¯${\textstyle {\overline {\mathbb {K} }}} the algebraic closure of the field K{\textstyle \mathbb {K} }. Then the ξ$_1$, …, ξ$_s${\textstyle \xi _{1}, \dots , \xi _{s}} have to be singularities of the equation (i.e. roots of p$_0${\textstyle p_{0}} or p$_r${\textstyle p_{r}}). Furthermore one can compute bounds for the exponents e$_i${\textstyle e_{i}}. For fixed values ξ$_1$, …, ξ$_s$, e$_1$, …, e$_s${\textstyle \xi _{1}, \dots , \xi _{s}, e_{1}, \dots , e_{s}} it is possible to make an ansatz which gives candidates for z{\textstyle z}. For a specific z{\textstyle z} one can again make an ansatz to get the rational function r(n){\textstyle r(n)} by Abramov's algorithm. Considering all possibilities one gets the general solution of the recurrence equation.

### D'Alembertian solutions

A sequence $y$ is called d'Alembertian if y=h$_1$∑h$_2$∑⋯∑h$_k${\textstyle y=h_{1}\sum h_{2}\sum \cdots \sum h_{k}} for some hypergeometric sequences h$_1$, …, h$_k${\textstyle h_{1}, \dots , h_{k}} and y=∑x{\textstyle y=\sum x} means that Δy=x{\textstyle \Delta y=x} where Δ{\textstyle \Delta } denotes the difference operator, i.e. Δy=Ny−y=y(n+1)−y(n){\textstyle \Delta y=Ny-y=y(n+1)-y(n)}. This is the case if and only if there are first-order linear recurrence operators L$_1$, …, L$_k${\textstyle L_{1}, \dots , L_{k}} with rational coefficients such that L$_k$⋯L$_1$y=0{\textstyle L_{k}\cdots L_{1}y=0}.
1994 Abramov and Petkovšek described an algorithm which computes the general d'Alembertian solution of a recurrence equation. This algorithm computes hypergeometric solutions and reduces the order of the recurrence equation recursively.

## Examples
### Signed permutation matrices

The number of signed permutation matrices of size $n\times n$ can be described by the sequence y(n)∈Q$^N${\textstyle y(n)\in \mathbb {Q} ^{\mathbb {N} }}. A signed permutation matrix is a square matrix which has exactly one nonzero entry in every row and in every column. The nonzero entries can be ±1{\textstyle \pm 1}. The sequence is determined by the linear recurrence equation with polynomial coefficients$y(n)=4(n-1)^{2}\,y(n-2)+2\,y(n-1)$and the initial values y(0)=1, y(1)=2{\textstyle y(0)=1, y(1)=2}. Applying an algorithm to find hypergeometric solutions one can find the general hypergeometric solution$y(n)=c\,2^{n}n!$for some constant c{\textstyle c}. Also considering the initial values, the sequence y(n)=2$^n$n!{\textstyle y(n)=2^{n}n!} describes the number of signed permutation matrices.

### Involutions

The number of involutions y(n){\textstyle y(n)} of a set with n{\textstyle n} elements is given by the recurrence equation$y(n)=(n-1)\,y(n-2)+y(n-1).$Applying for example Petkovšek's algorithm it is possible to see that there is no polynomial, rational or hypergeometric solution for this recurrence equation.

## Applications

A function F(n, k){\textstyle F(n, k)} is called hypergeometric if F(n, k+1)/F(n, k), F(n+1, k)/F(n, k)∈K(n, k){\textstyle F(n, k+1)/F(n, k), F(n+1, k)/F(n, k)\in \mathbb {K} (n, k)} where K(n, k){\textstyle \mathbb {K} (n, k)} denotes the rational functions in n{\textstyle n} and k{\textstyle k}. A hypergeometric sum is a finite sum of the form f(n)=∑$_k$F(n, k){\textstyle f(n)=\sum _{k}F(n, k)} where F(n, k){\textstyle F(n, k)} is hypergeometric. Zeilberger's creative telescoping algorithm can transform such a hypergeometric sum into a recurrence equation with polynomial coefficients. This equation can then be solved to get for example a linear combination of hypergeometric solutions which is called a closed form solution of f{\textstyle f}.