 # Factorization of C-finite Sequences

We discuss how to decide whether a given C-finite sequence can be written nontrivially as a product of two other C-finite sequences.

Comments

There are no comments yet.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

It is well known that when and are two sequences that satisfy some linear recurrences with constant coefficients, then the product sequence also satisfies such a recurrence. Sequences satisfying linear recurrences with constant coefficients are called C-finite [14, 6, 16], and the fact just refered to is one of several closure properties that this class of sequences enjoys. In this paper, we will consider the inverse problem: given a C-finite sequence , can we write it in a nontrivial way as the product of two other C-finite sequences? This question is of interest in its own right, but it is also useful in some applications in combinatorics. For example, the celebrated solution by Kasteleyn, and Temperley-Fisher, of the dimer problem [2, 5] as well as the even more celebrated Onsager solution of the two-dimensional Ising model  can be (re)discovered using an algorithm for factorization of C-finite sequences.

A C-finite sequence is uniquely determined by a recurrence and a choice of sufficiently many initial values. The prototypical example of a C-finite sequence is the Fibonacci sequence defined by

 Fn+2−Fn+1−Fn=0,F0=0,F1=1.

Whether a C-finite sequence admits a factorization depends in general on both the recurrence as well as the initial values. For example, the sequence , which satisfies the recurrence

 cn+4−21cn+3+158cn+2−504cn+1+576cn=0,

can be factored as , while the sequence , which satisfies the same recurrence, cannot be factored.

We shall consider a variant of the factorization problem that does not depend on initial values but only on the recurrence equations. Linear recurrences may be viewed as polynomials acting on sequences via

 p⋅(an)∞n=0:=(p0an+p1an+1+⋯+pdan+d)∞n=0.

For every fixed , denote by the set of all sequences with , i.e., the solution space of the recurrence equation encoded by

. This is a vector space of dimension

. For any two operators there exists a unique monic polynomial such that is vector space generated by all sequences with and , i.e., . We write .

Our problem shall be to decide, for a given monic polynomial , whether there exist such that . In principle, it is known how to do this. Singer  gives a general algorithm for the analogous problem for linear differential operators with rational function coefficients, the problem is further discussed in . Because of their high cost, these algorithms are mainly of theoretical interest. For the special case of differential operators of order 3 or 4 (still with rational function coefficients), van Hoeij [13, 12] combines several observations to algorithms which handle these cases efficiently. For the recurrence case, Cha  gives an algorithm for operators of order 3 with rational function coefficients. An algorithm for the case of constant coefficients and arbitrary order was recently sketched by the second author . This description however only considers the “generic case”. The present paper is a continuation of this work in which we give a complete algorithm which also handles “degenerate” cases. Our algorithm is efficient in the sense that it does not require any Gröbner basis computation, but inefficient in the sense that it requires a search that may take exponential time in the worst case.

## 2 Preliminaries

To fix notation, let us recall the basic facts about C-finite sequences. Let be an algebraically closed field.

###### Definition 1.
1. A sequence is called C-finite, if there exist with such that for all we have .

2. In this case, the polynomial is called a characteristic polynomial for .

3. For , the set denotes the set of all C-finite sequences whose characteristic polynomial is . It is called the solution space of .

###### Theorem 2.

[10, 6] Let for pairwise distinct . Then is the -vector space generated by the sequences

 ϕn1, …, ne1−1ϕn1, ϕn2, …, ne2−1ϕn2, ………, ϕnm, …, nem−1ϕnm.

It is an immediate consequence of this theorem that for any two polynomials we have and . The latter says in particular that when and are C-finite, then so is their sum . A similar result holds for the product: write and and define

 r:=p⊗q:=lcmmi=1lcmℓj=1(x−ϕiψj)ei+ϵj−1. (1)

Then is a characteristic polynomial for the product sequence . Note that for every . Note also that for every .

Our goal is to recover and from a given . The problem is thus to decide whether the roots of a given polynomial are precisely the pairwise products of the roots of two other polynomials and . Besides the interpretation as a factorization of C-finite sequences, this problem can also be viewed as factorization of algebraic numbers: given some algebraic number , specified by its minimal polynomial , can we write where are some other algebraic numbers with respective minimal polynomials and .

Trivial decompositions are easy to find: For each we obviously have . Moreover, for every nonzero we have , so we can “decompose” into and . In order for a decomposition to be interesting, we have to require that both and have at least degree 2.

Even so, a factorization is in general not unique. Obviously, if is a factorization, then for any nonzero  also . Translated to sequences, this ambiguity corresponds to the facts that for every , both and are C-finite, and that a sequence is C-finite iff for all the sequence is C-finite. But there is even more non-uniqueness: the polynomial

 r=(x−2)(x+2)(x−3)(x+3)

admits the two distinct factorizations

 r =(x−1)(x+1)⊗(x−2)(x+3) =(x−1)(x+1)⊗(x−2)(x−3)

which cannot be obtained from one another by introducing factors and . Our goal will be to compute a finite list of factorizations from which all others can be obtained by introducing factors .

There is a naive but very expensive algorithm which does this job when is squarefree: For some choice of degrees, make an ansatz and with variables . Equate the coefficients of with respect to to zero and solve the resulting system of algebraic equations for . After trying all possible degree combinations with , either a decomposition has been found, or there is none.

## 3 The Generic Case

Typically, when and are square-free polynomials and are the roots of and are the roots of , then the products for , will all be pairwise distinct. In this case, will have exactly roots, and the factorization problem consists in recovering and from the (known) roots of .

As observed in , a necessary condition for to admit a factorization into two polynomials of respective degrees and is then that there is a bijection such that for all we have

 ρπ(1,j1)ρπ(1,j2)=ρπ(2,j1)ρπ(2,j2)=⋯=ρπ(n,j1)ρπ(n,j2)

and for all we have

 ρπ(i1,1)ρπ(i2,1)=ρπ(i1,2)ρπ(i2,2)=⋯=ρπ(i1,m)ρπ(i2,m).

The explanation is simply that when a factorization exists, then the roots of  are precisely the products , and if we define so that it maps each pair to the corresponding root index , then the quotients

 ρπ(i,j1)ρπ(i,j2)=ϕiψj1ϕiψj2=ψj1ψj2

do not depend on and the quotients

 ρπ(i1,j)ρπ(i2,j)=ϕi1ψjϕi2ψj=ϕi1ϕi2

do not depend on .

In fact, the existence of such a bijection is also sufficient for the existence of a factorization: choose arbitrarily and set and

 ϕi:=ϕ1ρπ(i,1)ρπ(1,1)(i=2,…,n)

and

 ψj:=ψ1ρπ(1,j)ρπ(1,1)(j=2,…,m).

Then we have for all , and therefore for and we have . Note that and are squarefree, because if we have, say, for some , and then , and then , then .

###### Example 3.
1. Consider , i.e., , , , . A possible choice for is given by the table

(to be read like, e.g., ), because

 ρπ(1,2)ρπ(1,1)=ρ2ρ1=64=−9−6=ρ4ρ3=ρπ(2,2)ρπ(2,1)

and

 ρπ(2,1)ρπ(1,1)=ρ3ρ1=−64=−96=ρ4ρ2=ρπ(2,2)ρπ(1,2).

Take (for no particular reason), , , . Then

 (x−15)(x−452)⊗(x−415)(x+25) =(x−15415)(x+1525)(x−452415)(x+45225) =(x−4)(x+6)(x−6)(x+9),

as required.

In this example, no other factorizations exist except for those that are obtained by replacing and by and for some

. This degree of freedom is reflected by the arbitrary choice of

.

2. The polynomial cannot be written as for two quadratic polynomials and , because , , , , , .

3. Consider , i.e., , , , . We have seen that in this case there are two distinct factorizations. They correspond to the two bijections defined via

## 4 Product Clashes

Again let be two square-free polynomials, and write for the roots of and for the roots of . Generically, the degree of is equal to . It cannot be larger than this, and it is smaller if and only if there are two index pairs with . In this case, we say that and have a product clash. Recall from equation (1) that is formed as the least common multiple of the factors , not as their product.

Product clashes appear naturally in the computation of . For example, for we have

 p⊗p =lcm(x−ϕ1ϕ1,x−ϕ1ϕ2,x−ϕ2ϕ1,x−ϕ2ϕ2) =(x−ϕ1ϕ1)(x−ϕ1ϕ2)(x−ϕ2ϕ2),

because is a clash. More generally, if is a square-free polynomial of degree , then .

As an example that does not come from a product of the form , consider and . Here we have the clashes and , so that only has degree 4.

In order to include product clashes into the framework of the previous section, we need to relax the requirement that be injective. We still want it to be surjective, because every root of must be produced by the product of some root of and some root of . If the and the are defined according to the formulas above, it can now happen that for some . We therefore adjust the definition of and to , . Then and are squarefree and for the set of roots of we obtain

 {ϕiψj:i=1,…,n;j=1,…,m}={ρ1,…,ρℓ},

as desired.

###### Example 4.
1. To find the factorization , set , , . Then a suitable choice for is given by

because

 ρπ(1,1)ρπ(1,2)=ρ1ρ2=ϕ1ϕ2=ρ2ρ3=ρπ(2,1)ρπ(2,2)

and

 ρπ(1,1)ρπ(2,1)=ρ1ρ2=ϕ1ϕ2=ρ2ρ3=ρπ(1,2)ρπ(2,2).
2. Consider , i.e., , , , . A possible choice for is

because

 {ρπ(1,1)ρπ(1,2),ρπ(2,1)ρπ(2,2)}={ρ1ρ3,ρ2ρ1}={12} {ρπ(1,1)ρπ(1,3),ρπ(2,1)ρπ(2,3)}={ρ1ρ4,ρ2ρ3}={14} {ρπ(1,2)ρπ(1,3),ρπ(2,2)ρπ(2,3)}={ρ3ρ4,ρ1ρ3}={12}

and

## 5 Searching for Assignments

We now turn to the question how for a given we can find a map as required. Of course, since is finite, there are only finitely many possible choices for and such that , and for each choice there are only finitely many functions . We can simply try them all. But going through all these many functions one by one would take very long.

In order to improve the efficiency of the search, we can exploit the fact that for most partial functions it is easy to see that they cannot be extended to a total function with the required properties. We can further reduce the search space by taking into account that the order of the roots of the factors is irrelevant, i.e., we can restrict the search to functions with and . Furthermore, because of surjectivity, the root must be reached, and we can choose to set without loss of generality. Next, discard all functions with for some with or with for some with , because these just signal some roots of a factor of several times without providing any additional information. So we can in fact enforce and . Next, is a solution iff with is a solution. We can therefore restrict the search to functions where .

The following algorithm takes these observations into account. It maintains an assignment table which encodes a function  with

 ρπ(1,j1)ρπ(1,j2)=ρπ(2,j1)ρπ(2,j2)=⋯=ρπ(n,j1)ρπ(n,j2)

for all and

 ρπ(i1,1)ρπ(i2,1)=ρπ(i1,2)ρπ(i2,2)=⋯=ρπ(i1,m)ρπ(i2,m).

for all . At every recursion level, the candidate under consideration is extended to a function with for some . As soon as is chosen, there is for each at most one choice for the value of . The matrix stores these values and marks the indices for which no exists with . The result is a function for some . If this function is surjective, we have found a solution. Otherwise, we proceed recursively unless we already have , because in this case any further extension could only produce transposes of solutions that will be found at some other stage of the search.

INPUT: The roots of some square-free polynomial .
OUTPUT: A list of functions as required for solving the factorization problem.

1let be a matrix with for .

2call the procedure as defined below.

3stop.

4procedure

5for do:

6set the th row of to and let be the empty list

7for do:

8if and there exists such that and

9set and append to

10if then:

11report the solution with for all .

12else if then

13recursively call the procedure

In the interest of readability, we have refrained from some obvious optimizations. For example, an actual implementation might perform some precomputation in order to improve the search for in Step 8.

It is not hard to implement the algorithm. A Mathematica implementation by the authors is available on the website of this paper, http://www.math.rutgers.edu/~zeilberg/mamarim/mamarimhtml/Cfac.html. The relevant function is CFiniteFactor.

###### Example 5.

Let where , , , , , .

After initialisation, at the first level of the recursion, there are five choices for the first entry in the second row of . Each of them uniquely determines the rest of the row, as follows (writing for ):

 (1234562⋅4⋅⋅⋅), (123456345⋅6⋅), (1234564⋅⋅⋅⋅⋅), (1234565⋅6⋅⋅⋅), (1234566⋅⋅⋅⋅⋅).

The second of these matrices corresponds to a solution

 π:{1,2}×{1,2,3,4}→{1,2,3,4,5,6},

which gives rise to the factorization

 r=(x−1)(x−12)⊗(x+8)(x+6)(x+4)(x+2),

while the other partial solutions cannot be continued to further solutions.

## 6 Multiple Roots

Let us now drop the condition that is square free. Write for the square free part of . It is clear from equation (1) that when are such that , then , where denote the square free parts of and , respectively. It is therefore natural to first determine factorizations of the square free part of  and in a second step obtain and from and (if possible) by assigning appropriate multiplicities to their roots. As the multiplicities in or cannot exceed those in , there are again just finitely many candidates and we could simply try them all. And again, the search can be improved because many possibilities can be ruled out easily. In fact, the freedom for the multiplicities is so limited that we can compute them rather than search for them.

First consider the case when and were obtained from an injective map , i.e., the case when there are no product clashes. In this case, each root of corresponds to exactly one product of a root of and a root of . The multiplicities of in and of in , respectively, must be such that equals the multiplicity of in . This gives a linear system of equations. Every solution of this system in the positive integers gives rise to a factorization for , and if there is no solution for the linear system of any of the factorizations of the square-free part , then admits no factorization.

When there are product clashes, there are roots of which are obtained in several distinct ways as products of roots of and , for instance for some . If is the multiplicity of in , then the requirement for the multiplicities of in and , respectively, is that

 max(ei1+ϵj1−1,ei2+ϵj2−1)=m.

We obtain a system of such equations, one equation for reach root of . Such systems are known as tropical linear systems, and algorithms are known for finding their solutions in polynomial time .

###### Example 6.
1. Let . We have seen earlier that the square free part of admits two distinct factorizations

 r∗ =(x−1)(x+1)⊗(x−2)(x+3) =(x−1)(x+1)⊗(x−2)(x−3).

Assigning multiplicities to the first, we get

 (x−1)e1(x+1)e2⊗(x−2)ϵ1(x+3)ϵ2 =(x+2)e1+ϵ1−1(x−3)e1+ϵ2−1(x−2)e2+ϵ1−1(x+3)e2+ϵ2−1.

Comparing the exponents to those of  gives the linear system

 e1+ϵ1−1 =2, e1+ϵ2−1 =2, e2+ϵ1−1 =1, e2+ϵ2−1 =3,

which has no solution. For the second factorization, we get

 (x−1)e1(x+1)e2⊗(x−2)ϵ1(x−3)ϵ2 =(x+2)e1+ϵ1−1(x+3)e1+ϵ2−1(x−2)e2+ϵ1−1(x−3)e2+ϵ2−1.

Comparing the exponents to those of  gives the linear system

 e1+ϵ1−1 =2, e1+ϵ2−1 =3, e2+ϵ1−1 =1, e2+ϵ2−1 =2,

whose unique solution in the positive integers is , , , , thus

 r=(x−1)2(x+1)⊗(x−2)(x−3)2.
2. Let . We have seen earlier that the square free part of admits the factorization

 r∗=(x−12)(x−14