SOLVING LINEAR RECURSIONS OVER ALL FIELDS
KEITH CONRAD
1. Introduction
A sequence {an} = (a0, a1, a2,... ) in a field K satisfies a linear recursion if there are c1, . . . , cd ∈ K such that
(1.1) an = c1an−1 + c2an−2 + ··· + cdan−d for all n ≥ d. For example, the Fibonacci sequence {Fn} = (0, 1, 1, 2, 3, 5, 8,... ) is defined by the linear recursion Fn = Fn−1 +Fn−2 with initial values F0 = 0 and F1 = 1. (Often F0 is ignored, but the values F1 = F2 = 1 and the recursion force F0 = 0.) We will assume cd 6= 0 and then say the recursion has order d; this is analogous to the degree of a polynomial. For instance, the recursion an = an−1 + an−2 has order 2. The sequences in K satisfying a common recursion (1.1) are a K-vector space under termwise addition. The initial terms a0, a1, . . . , ad−1 determine the rest and if cd 6= 0 then we can set the initial d terms arbitrarily1, so solutions to (1.1) form a d-dimensional vector space in K. We seek an explicit basis for the solutions of (1.1) described by nice formulas.
Example 1.1. Solutions to an = an−1 + an−2 in R are a 2-dimensional space. A power n n n−1 n−2 2 sequence λ with λ 6= 0 satisfies it when λ = λ√ +λ , which is equivalent√ to λ √= λ+1. 2 1± 5 1+ 5 n 1− 5 n That makes λ a root of x − x − 1, so λ = 2 . The sequences ( 2 ) and ( 2 ) are not scalar multiples, so they are a basis: in R if an = an−1 + an−2 for all n ≥ 2 then √ !n √ !n 1 + 5 1 − 5 a = α + β n 2 2 for unique α and β in R. The Fibonacci sequence {F } is the special case where a = 0 and √ √ n √ 0 √ a = 1. Solving α + β = 0 and α( 1+ 5 ) + β( 1− 5 ) = 1 we get α = 1/ 5 and β = −1/ 5 1 2 2 √ √ when a = F . The solution with a = 1 and a = 0 uses α = − 1−√ 5 and β = 1+√ 5 . n n 0 1 2 5 2 5 2 If we replace R by any field K in which x − x − 1 has√ roots, even a field of characteristic 1± 5 p, the computations above still work if we replace 2 by the roots in K unless K has characteristic 5: there x2 − x − 1 = x2 + 4x + 4 = (x + 2)2 so 3 is the only root and the n only power sequence satisfying an = an−1 + an−2 is {3 } = (1, 3, 4, 2, 1, 3, 4, 2 ... ).
Example 1.2. Let K have characteristic 5. What nice formula fits an = an−1 + an−2 and n n−1 is linearly independent of {3 } = (1, 3, 4,... )? The sequence an = n3 works since 4 a + a = 3n−3((n − 1)3 + (n − 2)) = 3n−3(4n) = n3n = n3n−1 = a . n−1 n−2 27 n n This starts out as (0, 1, 1, 2, 3, 0, 3, 3,... ), so it is Fn mod 5 and is not a multiple of {3 }.
1 What if cd = 0? If an = 2an−1 then the first term determines the rest, so the solution space is 1- dimensional. Writing the recursion as an = 2an−1 + 0an−2 doesn’t make the solution space 2-dimensional unless we insist the recursion is for n ≥ 2 rather than for n ≥ 1. We will not address this option. 1 2 KEITH CONRAD
How is {n3n−1} found? If {λn} and {µn} satisfy the same linear recursion, so does any linear combination. If λ 6= µ a linear combination is (λn − µn)/(λ − µ), and as µ → λ this “becomes” {nλn−1}, which up to scaling is {nλn}.2 This suggests that since 3 is a double root of x2 − x − 1 in characteristic 5, {n3n−1} should be a solution and we saw it really is. n−1 The formula Fn ≡ n3 mod 5 goes back at least to Catalan [3, p. 86] in 1857. Our goal is to prove the following theorem about a basis for solutions to a linear recursion over a general field K.
Theorem 1.3. Let an = c1an−1 + c2an−2 + ··· + cdan−d be a linear recursion of order d 2 d with ci ∈ K. Assume 1 − c1x − c2x − · · · − cdx factors in K[x] over its reciprocal roots – the λ such that 1/λ is a root – as
e1 er (1 − λ1x) ··· (1 − λrx) ,
where the λi are distinct and ei ≥ 1. A basis for the solutions of the linear recursion in K is given by the e sequences {λn}, {nλn}, { nλn},..., { n λn} for i = 1, . . . , r. i i i 2 i ei−1 i Example 1.4. The simplest case of Theorem 1.3 is when each reciprocal root has multiplic- 2 d ity 1: if 1 − c1x − c2x − · · · − cdx = (1 − λ1x) ··· (1 − λdx) has d distinct reciprocal roots λi n n n then the solutions of (1.1) are unique linear combinations of the λi : an = α1λ1 +···+αdλd . Example 1.5. The recursion an = 8an−1 −24an−2 +32an−3 −16an−4 has order 4 if K does not have characteristic 2. Since 1 − 8x + 24x2 − 32x3 + 16x4 = (1 − 2x)4, the solutions have n n n n n n n n n basis {2 }, {n2 }, { 2 2 }, and { 3 2 }, so every solution is (b0 + b1n + b2 2 + b3 3 )2 for unique bi ∈ K. The classical version of Theorem 1.3 in C, or more generally characteristic 0, is due to k n Lagrange and says a basis of the solutions is the sequences {n λi } for k < ei and i = 1, . . . , r. This works in characteristic p if all ei ≤ p but breaks down if any ei > p, so it’s essential to n n k n use { k λi } to have a result valid in all fields. While n mod p has period p in n, k mod p n has a longer period if k ≥ p. For instance, in characteristic 2 the sequence 2 mod 2 has period 4 with repeating values 0, 0, 1, 1 when n runs through the nonnegative integers. We will prove Theorem 1.3 in two ways: by generating functions and by an analogy with differential equations. Anna Medvedovsky brought this problem in characteristic p to my attention and the second proof is a variation on hers. After writing this up I found a result equivalent to Theorem 1.3 in a paper of Fillmore and Marx [4, Thm. 1, 2] and the case of finite K in McEliece’s Ph.D. thesis [5, p. 19]. The earliest paper I found mentioning the n n basis { k λi } in characteristic p is by Engstrom [2, p. 215] in 1931 when max ei = p, but k n {n λi } still works in that case. In 1933, Milne-Thomson [7, p. 388] in characteristic 0 gave k n n−1 n the basis {n λi } and remarked that the alternative { k λi } “is sometimes convenient.” 2. First Proof: Generating Functions n d It is easy to show the sequence {λ } fits (1.1) if λ is a reciprocal root of 1−c1x−· · ·−cdx : n n−1 n−2 n−d d d−1 d−2 λ = c1λ + c2λ + ··· + cdλ for all n ≥ 0 ⇐⇒ λ = c1λ + c2λ + ··· + cd d d−1 ⇐⇒ λ − c1λ − · · · − cd = 0, c c ⇐⇒ 1 − 1 − · · · − d = 0. λ λd
2There is an analogous result in differential equations: the solution space to y00(t) + ay0(t) + by(t) = 0 has basis {eλt, eµt} if λ and µ are different roots of x2 + ax + b. If x2 + ax + b has a double root λ then a basis of the solution space is {eλt, teλt}. So λn ↔ eλt and nλn ↔ teλt. We’ll return to this analogy in Section3. SOLVING LINEAR RECURSIONS OVER ALL FIELDS 3