The Truncated Fourier Transform and Applications

Joris van der Hoeven

Dépt. de Mathématiques (Bât. 425)

Université Paris-Sud

91405 Orsay Cedex

France

Email: joris@texmacs.org

January 9, 2004

In this paper, we present a truncated version of the classical Fast Fourier Transform. When applied to polynomial multiplication, this algorithm has the nice property of eliminating the “jumps” in the complexity at powers of two. When applied to the multiplication of multivariate polynomials or truncated multivariate power series, we gain a logarithmic factor with respect to the best previously known algorithms.

Keywords: Fast Fourier Transform, jump phenomenon, truncated multiplication, FFT-multiplication, multivariate polynomials, multivariate power series.

A.M.S. subject classification: 42-04, 68W25, 42B99, 30B10, 68W30.

1.Introduction

Let be an effective ring of constants (i.e. the usual arithmetic operations , and can be carried out by algorithm). If has a primitive -th root of unity with , then the product of two polynomials with can be computed in time using the Fast Fourier Transform or FFT [CT65]. If does not admit a primitive -th root of unity, then one needs an additional overhead of in order to carry out the multiplication, by artificially adding new root of unity [SS71, CK91].

Besides the fact that the asymptotic complexity of the FFT involves a large constant factor, another classical drawback is that the complexity function admits important jumps at each power of two. These jumps can be reduced by using -th roots of unity for small . They can also be smoothened by decomposing -multiplications as -, - and -multiplications. However, these tricks are not very elegant, cumbersome to implement, and they do not allow to completely eliminate the jump problem.

In section 3, we present a new kind of “Truncated Fourier Transform” or TFT, which allows for the fast evaluation of a polynomial in any number of well-chosen roots of unity. This algorithm coincides with the usual FFT if is a power of two, but it behaves smoothly for intermediate values. In section 4, we also show that the inverse operation of interpolation can be carried out with the same complexity (modulo a few additional shifts).

The TFT permits to speed up the multiplication of univariate polynomials with a constant factor between and . In the case of multivariate polynomials, the repeated gain of such a constant factor leads to the gain of a non-trivial asymptotic factor. More precisely, assuming that admits sufficiently -th roots of unity, we will show in section 5 that the product of two multivariate polynomials can be computed in time , where and . The best previously known algorithm [CKL89], based on sparse polynomial multiplication, has time complexity .

In section 6 we finally give an algorithm for the multiplication of truncated multivariate power series. This algorithm, which has time complexity , again improves the best previously known algorithm [LS03] by a factor of . Moreover, both in the cases of multivariate polynomials and power series, we expect the corresponding constant factor to be better.

2.The Fast Fourier Transform

Let be an effective ring of constants, with and a primitive -th root of unity (i.e. ). The discrete Fast Fourier Transform (FFT) of an -tuple (with respect to ) is the -tuple with

In other words, , where denotes the polynomial .

The F.F.T can be computed efficiently using binary splitting: writing

we recursively compute the Fourier transforms of and

Then we have

This algorithm requires multiplications with powers of and additions (or subtractions).

In practice, it is most efficient to implement an in-place variant of the above algorithm. We will denote by the bitwise mirror of at length (for instance, and ). At step , we start with the vector

At step , we set

(1)

for all and , where . Using induction over , it can easily be seen that

for all and . In particular,

for all . This algorithm of “repeated crossings” is illustrated in figure 1.

Figure 1. Schematic representation of a Fast Fourier Transform for . The black dots correspond to the , the upper row being and the lower row .

A classical application of the FFT is the multiplication of polynomials and . Assuming that , we first evaluate and in using the FFT:

We next compute the evaluations of at . We finally have to recover from these values using the inverse FFT. But the inverse FFT with respect to is nothing else as times the direct FFT with respect to . Indeed, for all and all , we have

(2)

since

whenever . This yields a multiplication algorithm of time complexity in , when assuming that admits enough primitive -th roots of unity. In the case that does not, then new roots of unity can be added artificially [SS71, CK91, vdH02] so as to yield an algorithm of time complexity .

3.The Truncated Fourier Transform

The algorithm from the previous section has the disadvantage that needs to be a power of two. If we want to multiply two polynomials such that , then we need to carry out the FFT at precision , thereby losing a factor of . This factor can be reduced using several tricks. For instance, one may decompose the -product into an product, an -product and an -product. This is efficient for small , but not very good if . In the latter case, one may also use an FFT at precision , by using -matrices at one step of the FFT computation. However, all these tricks of the trade require a large amount of hacking and one always continues to lose a non-trivial factor between and .

The idea behind the Truncated Fourier Transform is to provide an efficient algorithm for the evaluation of polynomials in any number of distinct points. Moreover, the inverse operation of interpolation can be carried out with the same complexity (modulo a few additional shifts). This technique will eliminate the “jumps” in the complexity of FFT multiplication.

So let , (usually, ) and let be a primitive -th root of unity. Given an -tuple , we will evaluate the corresponding polynomial in . We call the Truncated Fourier Transform (TFT) of . Now consider the completion of the -tuple into an -tuple . When using the in-place algorithm from the previous section in order to compute , we claim that many of the computations of the can actually be skipped (see figure 2). Indeed, at stage , it suffices to compute the vector . Besides , we therefore compute at most additional values. In total, we therefore compute at most values . This proves the following result:

Theorem 1. Let , and let be a primitive -th root of unity in . Then the Truncated Fourier Transform of an -tuple w.r.t. can be computed using at most additions (or subtractions) and multiplications with powers of .

Figure 2. Schematic representation of a TFT for and .

Remark 2. Assume that admits a privileged primitive -th root of unity for every , such that for all . Then the TFT of an -tuple w.r.t. with does not depend on the choice of . We call the TFT of w.r.t. the privileged sequence of roots of unity.

Remark 3. Since the only operations we need for computing the TFT are additions, subtractions and multiplications by powers of , the algorithm naturally combines with Schönhage-Strassen's algorithm when is a symbolically added root of unity.

Remark 4. If , then the TFT of can be computed using ring operations using a similar algorithm as above. More generally, this allows the rapid transformation of “unions of segments”.

4.

Inverting the Truncated Fourier Transform

Unfortunately, the inverse TFT cannot be computed using a similar formula as (2). Indeed, starting with the , we need to compute an increasing number of when decreases. Therefore we will rather invert the algorithm which computes the TFT, but with this difference that we will sometimes need with in order to compute . We will use the fact that whenever one value among , and one value among , are known in the cross relation (1), then we can deduce the others from them using one multiplication by a power of and two “shifted” additions or subtractions (i.e. the results may have to be divided by ).

More precisely, let us denote and at each stage . We use a recursive algorithm which takes the values and on input, and which computes . If , then we have nothing to do. Otherwise, we distinguish two cases:

The two cases are illustrated in figures 3 resp. 4. Since , the application of our algorithm for computes the inverse TFT. We notice that the values with are computed in decreasing order (for ) and the values with in increasing order. In other words, the algorithm may be designed in such a way to remain in place. We have proved:

Theorem 5. Let , and let be a primitive -th root of unity in . Then the -tuple can be recovered from its Truncated Fourier Transform w.r.t. using at most shifted additions (or subtractions) and multiplications with powers of .

Figure 3. Schematic representation of the recursive computation of the inverse TFT for , . The different images show the progression of the known values (the black dots) during the different computations at stage . Since , we fall into the first case of our algorithm and the recursive invocation of the algorithm is done between the third and the fourth image.

Figure 4. Schematic representation of the recursive computation of the inverse TFT for , at stage . Since and , we now fall into the second case of our algorithm and the recursive invocation of the algorithm is done between the third and the fourth image.

Remark 6. Besides shifted additions, subtractions or multiplications by powers of , the algorithm essentially computes inverse FFT-transforms of sizes with . Using (2), it is therefore possible to replace all but shifted additions and subtractions by normal additions and subtractions.

5.Multiplying multivariate polynomials

Let be a ring with a privileged sequence of roots of unity (see remark 2). Given a non-zero multivariate polynomial

in variables, we define the total degree of by

We let . Now let be such that . In this section we present an algorithm to compute , which has a good complexity in terms of the number

of expected coefficients of . When computing using the classical FFT with respect to each of the variables , we need a time which is much bigger than , in general. When using multiplication of sparse polynomials [CKL89], we need a time with a non-trivial constant factor. Our algorithm is based on the TFT w.r.t. all variables and we will show that it has a complexity .

Given with , the TFT of with respect to one variable at order is defined by

where . We recall that the result does not depend on the choice of . The TFT with respect to all variables at order is defined by

where (see figure 5). We have

Given with , we will use the formula

in order to compute the product .

Figure 5. Illustration of the TFT in two variables ().

In order to compute , say for , we compute the TFT of with for all with (if , then the TFT of is given by itself, so we have nothing to do). One such computation takes a time for some universal constant , by using the TFT w.r.t. with minimal (so may vary as a function of , but not ). The computation of therefore takes a time with

Dividing by , we obtain

(3)

If , then the summand rapidly deceases when , so that

Consequently, and even for fixed . If , then for and , Stirling's formula yields

It follows that only the first terms in (3) contribute to the asymptotic behaviour of , so that

Again, we find that . We have proved:

Theorem 7. Let be a ring with a privileged sequence of roots of unity. Let be polynomials with and let . Then the product can be computed using ring operations in .

6.Multiplying multivariate power series

Since power series have infinitely many terms, implementing an operation on power series really corresponds to implementing the operation for polynomial approximations at all degrees. As usual, multiplication is a particularly important operation. Given with and , we will show how to compute the truncated product of and .

The first idea [LS03] is to use homogeneous coordinates instead of the usual ones:

This transformation takes no time since it corresponds to some re-indexing. We next compute the TFTs and in at order :

We next compute the truncated products of the obtained polynomials and . After transforming the results of these multiplication back using

we obtain the truncated product of and by

The total computation time is bounded by . Using the fact that , we have proved the following theorem:

Theorem 8. Let be a ring with a privileged sequence of roots of unity. Let be polynomials of degrees and let . Then the truncated product of and at degree can be computed using ring operations in .

Remark 9. In practice, if the coefficients have different growths in , then it may be useful to consider truncations along more general degrees of the form

The “slicing technique” from section 6.3.5 in [vdH02] may then be used in order to obtain complexity bounds of the same type.

Remark 10. Using remark 4, the polynomial and truncated multiplication algorithms can be used in combination with the strategy of relaxed evaluation [vdH97, vdH02, vdH03b] for solving partial differential equations in multivariate power series with an additional overhead of . A recent technique [vdH03a] allows to reduce this overhead even further and it would be interesting to study more precisely what happens in the multivariate case.

7.Final notes

The author would like to thank the first referee for his enthusiastic and helpful comments. This referee also implemented the algorithms from sections 3 and 4 and he reports a behaviour which is close to the expected one. In response to some other comments and suggestions, we conclude with the following remarks:

Bibliography

[Ber]

D. Bernstein. Fast multiplication and its applications. Available from http://cr.yp.to/papers.html#multapps. See section 4, page 11.

[CK91]

D.G. Cantor and E. Kaltofen. On fast multiplication of polynomials over arbitrary algebras. Acta Informatica, 28:693–701, 1991.

[CKL89]

J. Canny, E. Kaltofen, and Y. Lakshman. Solving systems of non-linear polynomial equations faster. In Proc. ISSAC '89, pages 121–128, Portland, Oregon, A.C.M., New York, 1989. ACM Press.

[CT65]

J.W. Cooley and J.W. Tukey. An algorithm for the machine calculation of complex Fourier series. Math. Computat., 19:297–301, 1965.

[HQZ00]

Guillaume Hanrot, Michel Quercia, and Paul Zimmermann. Speeding up the division and square root of power series. Research Report 3973, INRIA, July 2000. Available from http://www.inria.fr/RRRT/RR-3973.html.

[HQZ02]

Guillaume Hanrot, Michel Quercia, and Paul Zimmermann. The middle product algorithm I. speeding up the division and square root of power series. Accepted for publication in AAECC, 2002.

[HZ04]

Guillaume Hanrot and Paul Zimmermann. A long note on Mulders' short product. JSC, 37(3):391–401, 2004.

[LS03]

G. Lecerf and É. Schost. Fast multivariate power series multiplication in characteristic zero. SADIO Electronic Journal on Informatics and Operations Research, 5(1):1–10, September 2003.

[Mul00]

T. Mulders. On short multiplication and division. AAECC, 11(1):69–88, 2000.

[Pan94]

Victor Y. Pan. Simple multivariate polynomial multiplication. JSC, 18(3):183–186, 1994.

[SS71]

A. Schönhage and V. Strassen. Schnelle Multiplikation grosser Zahlen. Computing 7, 7:281–292, 1971.

[vdH97]

J. van der Hoeven. Lazy multiplication of formal power series. In W. W. Küchlin, editor, Proc. ISSAC '97, pages 17–20, Maui, Hawaii, July 1997.

[vdH02]

J. van der Hoeven. Relax, but don't be too lazy. JSC, 34:479–542, 2002.

[vdH03a]

J. van der Hoeven. New algorithms for relaxed multiplication. Technical Report 2003-44, Université Paris-Sud, Orsay, France, 2003.

[vdH03b]

J. van der Hoeven. Relaxed multiplication using the middle product. In Manuel Bronstein, editor, Proc. ISSAC '03, pages 143–147, Philadelphia, USA, August 2003.