Closed-form solution of a general three-term recurrence relation

We present a closed-form solution for n-th term of a general three-term recurrence relation with arbitrary given n-dependent coefficients. The derivation and corresponding proof are based on two approaches, which we develop and describe in detail. First, the recursive-sum theory, which gives the exact solution in a compact finite form using a recursive indexing. Second, the discrete dimensional-convolution procedure, which transforms the solution to the non-recursive expression of n, including a finite number of elementary operations and functions.


I. INTRODUCTION
A general three-term recurrence relation is usually defined by the following expression: where n ≥ 1 (n ∈ N), W n is unknown function of n, A n and B n are arbitrary given functions of n, and W 0 = C 0 , W 1 = C 1 are initial conditions (we assume not a trivial case when C 1 = C 0 = 0 and W n ≡ 0). This well-known relation has a large number of applications and plays an important role in many areas of mathematics and physics. We note here only few of them to underline the importance of the proposed statement.
First, the recurrence relation Eq.(1) corresponds to the finite difference equation for the general second order differential equation with unknown function f (x) and arbitrary given U (x), namely: f ′′ − U (x) · f = 0. Therefore, it is widely used for the analytical and numerical analysis (and approximations) in corresponding physical and mathematical applications, see for example [1].
Second, three-term recurrence relations appear naturally when one uses Frobenius method for solving some linear differential equations and studying some special functions, see [2].
Third, the relation Eq.(1) corresponds to the continued fraction with arbitrary given coefficients. Basically, the three-term recurrence relation corresponds to the expressions for the numerators and denominators of this continued fraction (see chapter IV in [3]), which were derived by Euler.
In this manuscript we obtain a closed-form solution of a canonical three-term recurrence relation, which is equivalent to Eq.(1) in the case of (A n = 0, ∀n). Our goal is to obtain the solution consisting of a finite number of terms, rather than a variety of methods with infinite series [4]. In that way we develop two approaches for the expressions with a finite number of terms. We start with the recursive-sum theory, which is presented in sec.III. It allows to obtain the exact solution of the three-term recurrence relation in a compact form using a recursive indexing. Next, we develop the discrete dimensional-convolution procedure, which allows to eliminate recursive indexing and represent the solution as a closed-form expression. It means, that the final closed-form expression depends on arbitrary given coefficients and includes a finite number of elementary operations, such as: " + ", " − ", " × ", " ÷ "; and elementary functions, such as: Heaviside step function (or unit step function) and floor function for integer division.

II. PRELIMINARIES
Let us start from the simplification of the Eq.(1). For this we assume that A n = 0, ∀n (opposite case is not usually defined as a standard three-term recurrence relation and should be considered separately). Thus, we can use the following substitution: According to this substitution and Eq.(1), a n is fulfilled the following three-term recurrence relation: * ivan.gonoskov@gmail.com a n+1 = a n + B n A n A n−1 · a n−1 .
Since the Eq.(1), Eq.(3) are linear and n, A n , B n are arbitrary, we could assume without loss of generality the following initial conditions: a 0 = 1, a 1 = 1. Finally, we specify d n = B n · (A n A n−1 ) −1 as an arbitrary given function of n, and write below the expression, which we further call canonical three-term recurrence relation: a n+1 = a n + d n · a n−1 , a 0 = 1, a 1 = 1.
We note, that the solution of Eq.(4) consist of a sum of d i -products (i ∈ N) with different powers. Here we mean that the product power p is equal to the total number of d i in the product. The maximum power of a n+1 , i.e. the largest power among all the products in a n+1 , is equal to (n + 1)/2 , since: where we use Gauss notation for the integer division: Because of this fundamental characteristic it is natural to express a n+1 , i.e. the solution of Eq.(4), in the following form: where S(n, p) includes all terms of the power p. In the next sections we demonstrate that each S(n, p) is equal to the corresponding recursive-sum, and rigorously proof all the propositions.

III. RECURSIVE-SUM THEORY
In this section we start from the definition of a general recursive-sum (R-sum). Next, we present and proof some of its properties, which could determine the R-sum algebra. It could be useful for solving different recurrence relations, but, particularly for the solution of the canonical three-term recurrence relation it is sufficient to use a particular case of R-sum, namely reduced R-sum which is described in the next section.
Definition I: A general R-sum (R) is defined for the ordered sequence (d i , i ∈ Z) by the following expression: where (N, k, ∆, ∆ 0 ∈ Z), i 0 ≡ ∆ 0 , N is an order of the R-sum, k ≥ 1 is a power of the R-sum, ∆ is a recursive shift of the R-sum, ∆ 0 is an initial shift of the R-sum. For the correct definition it is also assumed that N ≥ ∆ 0 and d i is defined for all indexes used in Eq.(7). The product in Eq.(7) corresponds to the standard left-to-right order of multiplication, so the definition could be written also in the following way: Next, we present some of the R-sum elementary properties P.(1-3), which are following directly from the definition.
P. (1): P. (2): P. (3): Finally, we consider the R-sum key lemma: If N ≥ ∆ 0 + 1, then: Proof of the key lemma: and try to eliminate index numbers which correspond to zero terms in the original expression. For the correct procedure (when an upper bound in each sum is always not less than the lower one) we will eliminate zero terms and delete the corresponding index numbers step by step from i 1 to i k+1 .
At the next step we note that for i 1 = N + ∆ according to the definition we have only one value i 2 = N + 2∆ and one term d N +2∆ in the second sum in Eq.(13). According to the definition and P.(1) the same is true for the other indexes: i 3 = N + 3∆, ..., i k = N + k∆. The last term in Eq.(13) gives This means that all the terms in Eq.(13) which correspond to i 1 = N + ∆ are equal to zero. Since the condition (N ≥ ∆ 0 + 1), we could then write: The same procedure can be repeated for any successive indexes. Consider the m-th sum (m ≤ k) in Eq.(13). For each i m = N + m∆ we have only one term in the next sum, corresponding to i m+1 = N + (m + 1)∆, and so on until the last term: So we can delete all the corresponding index numbers and write: Finally, we note that Thus we obtain: which proves the key lemma.

IV. EXACT SOLUTION OF A CANONICAL THREE-TERM RECURRENCE RELATION VIA FINITE R-SUM EXPANSION
In this section we start with a definition of a reduced R-sum, a particular case of the general R-sum. Then, we construct the exact solution of the canonical three-term recurrence relation, by using the R-sum key lemma.
Definition II: A reduced R-sum (R) is a particular case of the general R-sum (see Eqs.(7-8)), and defined by the following expression: The key lemma Eq.(12) gives the following for the reduced R-sum: Since N and k are independent and arbitrary, let us consider them as functions of new numbers n and p: N = N (n, p) = n − 2p ; k = k(n, p) = p . In that way we consider a new subsidiary function: According to the previous notations we have: N (n, p) = n − 2p = n − 2k = N (n + 2, p + 1) = N (n + 1, p + 1) + 1.
Now, we will rigorously proof a theorem about the exact solution of a canonical three-term recurrence relation Eq.(4).

Theorem I
Exact solution of Eq.(4) is following: Proof of the theorem I.
Our proof is based on mathematical induction. Base cases: n = 1 : S(1, p). n = 2 : S(2, p), n = 3 : Inductive step: we will proof that the statement Eq.(21) for a n and a n−1 , ∀n gives the following: a n + d n · a n−1 = a n+1 .

V. DISCRETE DIMENSIONAL-CONVOLUTION PROCEDURE
In this section we develop a procedure which could be used for the transformation of the exact solution Eq.(21) to the expression without recursive indexing.
Let us start from a simple case to demonstrate the idea of the discrete dimensional-convolution procedure. We consider a simple expression, which could be associated with a particular case of R-sum.
where N 1 , N 2 ∈ N, (N 1 ≤ N 2 ) are arbitrary given natural numbers; δ ∈ N, is an arbitrary given natural number (shift); and f (i 1 , i 2 ) is an arbitrary given function of natural index numbers i 1 and i 2 . The previous expression E 2 could be rewritten as follows: where , and H(x) is Heaviside step function (or unit step function): Let us consider now the expression Eq.(32). The indexes i 1 and i 2 could be associated with two dimensions by the following way. Let us consider a two dimensional plot (array with elements F (i 1 , i 2 )) with horizontal numbering related to i 1 index and vertical numbering related to i 2 index, see the figure below.
For numbering of this array of elements it is possible to use a traversal rule with one global index q ∈ [1, . . . , N 1 · N 2 ] instead of i 1 ∈ [1, . . . , N 1 ] and i 2 ∈ [1, . . . , N 2 ]. Consider, for example, the following rule: q = i 1 + N 1 · (i 2 − 1), with the corresponding relations * : Since, for the presented rule, a unique combination of (i 1 , i 2 ) corresponds to a certain unique number q and vice versa (i.e. we have one-to-one mapping), we could rewrite the Eq.(32) in the following form: The presented procedure, i.e. the reduction from two dimensions to one dimension, is a particular case of discrete dimensional-convolution procedure. Let us now generalize it to a multidimensional case. In that way we consider a multidimensional analog of Eq.(32): where (k ∈ N), k ≥ 3 -is an arbitrary given natural number, (N 1 , N 2 , . . . , N k ∈ N) -is an array of arbitrary given natural numbers, and F (i 1 , i 2 , . . . , i k ) -is an arbitrary given function of i 1 , i 2 , . . . , i k . The previous expression is related to the calculation of a reduced R-sum. According to the definition of the reduced R-sum Eq.(17) and the substitution from Eqs.(31-32) we could write: where N j = N + 2j, (j ∈ N), and H(x) -is the unit step function (see Eq.(33)).
Let us now define a global index q as follows: Note, that the minimum value q min = 1 corresponds to the case then every index number is equal to unity. The maximum value q max = N 1 · N 2 · · · · · N k corresponds to the case then every index number reaches its maximum, since the relation: Now we construct one-to-one mapping between the global index q and the index numbers (i 1 , . . . , i k ). For that we need to solve the Eq.(37), i.e. to express any certain index number as a function of q (not depending on any other index numbers). We do that separately for i 1 , i k , and all others i r , Obtaining of i 1 : Since (i 1 − 1) < N 1 , the expression (q − 1)/N 1 does not depend on any index numbers except i 1 . Thus, we obtain: Obtaining of i k : N j does not depend on any index numbers except i k . Thus we obtain: Obtaining of i r , (2 ≤ r ≤ [k − 1]): Here we make two steps, similar to the previous cases, in order to eliminate the dependence of higher and lower index numbers separately. Consider the following expression: According to Eq.(38) we have: h r − 1 < r j=1 N j . In addition, we have simple relations: u/v · v ≡ u for u < v , and u/v · v ≡ 0 for (u/v) ∈ N . Thus we obtain: Next, we perform a step similar to the one we performed when obtain i k (see also Eq.(40)).
Finally, we could write: As can be seen, Eq.(39) corresponds to Eq.(44) if we put formally r = 1. In addition, we could write N j . This means that Eq.(40) also corresponds to Eq.(44) if we put formally r = k.
According to the previous equations every certain unique index number combination corresponds to the unique value of q. In addition, the total number of different index number combinations is equal to the total number of different values of q. Thus, we can conclude that Eq.(45) describes the one-to-one mapping for Eq.(35), and we can write: Summarizing, the proposed procedure allows one to calculate a reduced R-sum without recursive indexing.