Solving Cyclotomic Polynomials by Radical Expressions

Andreas Weber and Michael Keckeisen

Abstract: We describe a Maple package that allows the solution of cyclotomic polynomials by radical expressions. We provide a function that is an extension of the Maple solve command. The major algorithmic ingredient of the package is an improvement of a method due to Gauss which gives radical expressions for roots of unity. We will give a summary for computations up to degree 100, which could be done within a few hours of cpu time on a standard workstation.

Keywords: solution in radicals, roots of unity, cyclotomic polynomials, , Gauss algorithm

Introduction extent, reducing the needed amount of memory at the same Niels Henrik Abel and Evariste Galois showed that polyno- time. For instance, the computations of radical expressions mial equations of degree higher than four cannot be solved by for the 47th, 59th, or 83rd failed with the previ- radical expressions in general. As Galois stated in his work, ous implementation, but can now be accomplished within a radical solutions exist if and only if the Galois group of the few hours. polynomial is solvable. Since the Galois group of a cyclotomic polynomial is The Algorithm Abelian, its Galois group is solvable, and so its solutions can First, we will show how the task of computing radical solu- be expressed by radical expressions. tions for cyclotomic polynomials can be reduced to the one proved this special case already in of calculating radical expressions for roots of unity. Second, 1797 and published it in 1801 in his master-work Disquisi- we will sketch the algorithm for the latter task, which mainly tiones Arithmeticae [1] as an extension of his work to deter- is the one given in [2]. mine which regular polygons can be constructed by compass and ruler. In this book Gauss describes an algorithm to com- RADICAL SOLUTIONS FOR CYCLOTOMIC POLY- pute radical expressions for primitive roots of unity. NOMIALS We implemented a variant of the algorithm of Gauss in The n-th cyclotomic polynomial over the rational numbers is Maple, which has an improved time complexity compared to of the form

Gauss’ original proposition.

n

The hard part of the proof and of the algorithm is to com- x

p x

Q

n

n

j n

p

x x

pute a radical expression for a primitive -th root of unity, gcd

j 

where p is a prime number. The improvement in our algo- rithm reduces the asymptotic time complexity in this case and its degree is

from

s

Y

 

Op p m logp

r r 

i i

n p p

i i 

to i

 

Q

Op m log p

s

r

i

p n

where i and is the Eulerian -Function, cf.

i

m p

where is the largest prime factor of . An analysis of [3, p. 13 and 169]. From the defining formula of it can

 the algorithm and the statement and proof of the proposition be seen that the inverse image of is finite. Thus, to

on which the improvement is based can be found in [2]. We determine whether or not an irreducible factor q of a polyno-

also refer to this paper for a description of the underlying mial is cyclotomic, it suffices to compare the j -th cyclotomic



j

ideas of Gauss’ algorithm and the statement of the theorems polynomial with q for all in . Maple provides the



that yield its correctness. function numtheory[invphi] to calculate ; the compu- Compared to the Maple-code given in [2], we managed tational costs of this function is negligible for the range of to improve the practical speed of the algorithm to a great arguments which are feasible for computing radical expres- sions.

Arbeitsbereich Symbolisches Rechnen, Fakultat¨ fur¨ Infor-

n p x

matik, Universitat¨ Tubingen,¨ 72076 Tubingen,¨ Germany, E-mail: Given the -th cyclotomic polynomial n , the task of

n g fweber,keckeise @informatik.uni-tuebingen.de; WWW: http://www- computing radical solutions can be reduced to finding a sr.informatik.uni-tuebingen.de radical expression for one root of unity, because this root will

MapleTech Vol. ???, No. ??, pp. 1–5; ISSN 1061-5733 $6.00 c Birkhauser¨ Boston 1999 1 Solving Cyclotomic Polynomials by Radical Expressions be primitive, e. g. a multiplicative generator for the others. second strategy is simply to reverse the ordering; this can be

Further, it suffices to find a primitive n-th root of unity to done by setting SwapPrimeOrder := true. As had to be ex- compute primitive roots of unity for all prime factors of n by pected in all our experiments the obtained computation times applying some relatively simple recursion formulas, see e. g. were far worse than with our default setting and the com- [4]. puted radical expressions were also larger; some examples are given below in Table 2.

RADICAL EXPRESSIONS FOR PRIMITIVE p -TH ROOTS OF UNITY How to Use the Library The hard part of the algorithm is to find a radical expression

The library is included in the file ‘radsolvelib‘. p for a primitive p-th root of unity, where is a prime number.

This part involves the computation of Gaussian periods, cf. read ‘radsolvelib‘:

p x All functionality is available via the function radsolve.

[1, 343]. If p denotes a primitive -th root of unity the

f k f k period for two integers and is defined by The command radsolve serves as an extension to the Maple

solve command. It returns radical solutions for all cyclo-

f 

X tomic factors of a polynomial with integer coefficients and

em

kg 

f k

p calls solve for the others.

m

Calling Sequence: radsolve(poly)

p

g p

where e and is a primitive -th root. In Maple a

f primitive p-th root can be computed by the function primroot Parameters: poly — an univariate polynomial with in the package numtheory. integer coefficients The Gaussian periods are generators of intermediate fields

The command radsolve(poly) returns the solutions of

Q of the number field p , which is a number field of degree

the univariate polynomial poly as radical expressions

p over the rationals. Using the modern terminology of intermediate fields the algorithm of Gauss works roughly as for all the irreducible factors of poly that are either cy- follows. Starting with the rationals, compute a radical ex- clotomic or of degree lower than four. pression for a generator of an intermediate field of prime de- In general, explicit solutions in terms of radicals for gree, i.e. an appropriate Gaussian period. After this task has polynomial equations of degree greater than four do been accomplished, compute a radical expression for a gen- exist if and only if the Galois group of the polynomial erator of another intermediate field (i.e. another Gaussian pe- is solvable. This is the case for cyclotomic polynomi- riod) whose relative degree over the other intermediate field als, since their Galois group is cyclic. radsolve(poly)

is of prime order. Continue this task until a radical expres- computes radical expressions for such cases and calls



Q g p sion for a generator of p , i.e. has been solve for the other factors of poly. In cases, where ex- computed. plicit solutions can’t be computed, implicit solutions The difficult part of Gauss’ algorithm is the lifting of rad- are given in terms of RootOfs. ical expressions from one intermediate field to another one.

We will not give the details of this lifting here but we refer to Note that to obtain explicit solutions for the general [2]. quartic polynomial equation you have to set the global The algorithm described above works for several sequences variable EnvExplicit to true, as explained in the topic

of intermediate fields to be constructed. All permutations on help to solve.

the list of prime factors of p give a possible sequence in the construction of the intermediate fields. Different permu- The output from radsolve is a sequence of solutions. tations give different results in general, and also the compu- The behaving of radsolve(poly) can be changed by us- tational costs are greatly affected by the choice of an appro- ing the following global variables (default values in priate sequence of intermediate fields. Our default strategy brackets): in the choice of the intermediate fields is as follows: first

take the largest prime factor, then the second largest and so AllSolutions (false): If AllSolutions is set to false,

Q radsolve(poly) on, until we just get the final field p as a relative exten- returns only one solution (no matter which sion of degree 2 of the last intermediate field. Note that we exponent belongs to the factor) for every irreducible have to count multiplicities as separate factors. This strategy factor of poly. If it is set to true, all solutions are given. seems to be preferable over others, because bigger relative extensions — which cause more computations — occur in UseRootsymbols (false): if UseRootsymbols is set to

smaller intermediate fields. However, as a tool for experi- true, RootOfs are used to represent primitive roots of

mental we provide another strategy, too. The unity of prime factors of n , where n is the degree of

2 MapleTech Solving Cyclotomic Polynomials by Radical Expressions

the cyclotomic polynomial, although these roots could To verify the results, one can use radnormal for smaller be expressed in radicals explicitly. This saves time and degrees only. One has to use numeric evaluation for larger space. If UseRootsymbols is set to false, all RootOfs degrees. The following method works for very large expres- are substituted by their radical expressions. sions.

restart:

SwapPrimeOrder (false): If SwapPrimeOrder is set read ‘radsolvelib‘:

to true, then an alternative order of building intermedi- _AllSolutions:=false:

p

ate generators of field extensions of order , where z:=radsolve(numtheory[cyclotomic](41,x)): m

Digits:=40: m p is the degree of the cyclotomic polynomial and di-

readlib(optimize):

vides p , is chosen. This results in different radical numeval:=‘optimize/makeproc‘(

expressions and in more computing time. Mainly for map(evalf,[optimize(z)])):

experimentation. fnormal(numeval()ˆ41-1,35);

To obtain information about the computing process, set infolevel[radsolve] to an appropriate level. Level 0 gives just the solutions, level 1 and level 2 are not Practical Limitations of the Algorithm used, level 3 gives a general outline, level 4 is nice Compared to [2] the implementation of the main algorithm to use for larger examples and level 5 is designed for has been optimized. For results in Table 1 we applied rad- those who are really interested in the algorithm. solve on all cyclotomic polynomials of (prime) degree up to 101 on a Sun Ultrasparc I workstation. It can be seen that EXAMPLES

the computing time depends on the size of the largest prime

The Maple solve command does not express the solutions of factor of p to a great extent, as had to be expected from a cyclotomic factor of a polynomial of degree higher than 4 the theoretical complexity analysis given in [2]. in radicals, but uses sin and cos functions instead. Memory usage was up to 20MB for p=83, less than 5MB

solve(xˆ7-1)[4]; for the rest. Table 1 was generated semi-automatically via

the following script.

cos I sin

restart: In the following, we set AllSolutions to false. Thus we read ‘radsolvelib‘: get only one solution for any irreducible factor of the poly- _UseRootsymbols:=true: nomial. _AllSolutions:=false:

_SwapPrimeOrder:=false:

restart: readlib(cost):

read ‘radsolvelib‘: additions:=‘f‘:

_AllSolutions:=false: multiplications:=‘f‘: lsols:=radsolve(xˆ7-1); divisions:=‘f‘:

functions:=‘r‘:

p assignments:=‘a‘:





lsols

readlib(optimize):

p p

for i from 7 to 101 do

if numtheory[isprime](i) then

 

 t:=round(time(

radsolve( p

numtheory[cyclotomic](

i,x)))):



z:= radsolve(numtheory[cyclotomic](i,x));

printf(‘\\n%5d %15A %20f %30A%30A‘,

p

i,numtheory[ifactor](i-1),

t,cost(z), p

cost(optimize(z)));

fi:

Using the radnormal command we can verify that the od: radical expression, which was returned by radsolve as a so- It is interesting to see the results you obtain by setting lution for the non-trivial factor, is indeed a 7th root of unity. SwapPrimeOrder := true. You get different radical expres- sions and it takes a lot more time and memory. Some exam-

radnormal(lsols[2]ˆ7-1);

ples are given in Table 2.

Vol. ???, No. ??, 1999 3 Solving Cyclotomic Polynomials by Radical Expressions

Table 1: Summary of Computations

The following computations times refer to our Maple implementation of the algorithm on a Sun Ultrasparc I workstation.

p p comp. size of term size of term time (tree rep.) (dag rep.) (in sec.) rational radical rational radical

operations operations operations operations

7 1 95 24 28 5

11 2 569 78 72 5

13 2 291 74 52 9 

17 2 55 38 34 12

19 5 1127 264 91 9

23 34 7941 442 323 5

29 18 5163 498 212 9

31 18 8337 1138 210 10

37 20 3567 822 153 15



41 26 6937 958 259 19

43 49 28110 2688 380 10

47 856 70126 2026 1218 5

53 151 39309 1878 593 9

59 2524 140127 3250 1863 5

61 89 27144 3730 317 20

67 206 120397 7052 729 10

71 237 87960 8374 595 10



73 114 17788 4052 305 25

79 362 201333 10002 947 10

83 13962 407621 6562 3682 5



89 342 113155 6608 920 19

97 216 10015 2566 256 37

101 388 68853 9194 643 19

Table 2: Some results with SwapPrimeOrder := true

All other settings were equal to the ones used for Table 1.

p p comp. size of term size of term time (tree rep.) (dag rep.) (in sec.) rational radical rational radical

operations operations operations operations

23 94 10282 649 662 5

43 194 12432 2495 554 10

71 807 90413 13219 980 10

4 MapleTech Solving Cyclotomic Polynomials by Radical Expressions

Comparison to Related Work Except for an implementation by ourselves of a much In the book of Gaal [4] a radical expression for a 7th root more inefficient method for the same task described in [5], of unity is derived by some special reasoning that does not we do not know of implementations of other general methods generalize to higher orders. The derived expression is the by which radical expressions for higher roots of unity can be following: computed. Without being aware of an implementation, we know of an algorithm developed by B. Trager, which com-

restart: read ‘radsolvelib‘:

putes radical expressions for a p-th root of unity [6]. This

A:=-1/6+(7/2+21/2*sqrt(-3))ˆ(1/3)/6

+(7/2-21/2*sqrt(-3))ˆ(1/3)/6 algorithm is entirely different from the one of Gauss. The

+(sqrt((-1/3+(7/2+21/2*sqrt(-3))ˆ(1/3)/3 major computational task consists of inverting a matrix of

+(7/2-21/2*sqrt(-3))ˆ(1/3)/3)ˆ2-4))/2;

Op Q q p

size over q , where is a divisor of . Thus if

p

p is smooth, i.e. if contains only small prime fac-

p



I

A tors, the asymptotic time complexity of our improvement of

the algorithm of Gauss is much better. But in special cases,

p

p



I

such that is prime, the algorithm of Trager might be an

interesting alternative. It would be interesting to have a care-

p p

 

p

I I

ful implementation of the hard cases, such as

etc.



Our function radsolve computes: Acknowledgment

B:=radsolve(xˆ6+xˆ5+xˆ4+xˆ3+xˆ2+x+1); A. Weber was partially supported by Deutsche Forschungs-

gemeinschaft under grants We 1945/1-1 and Ku 966/6-1. We

p

are grateful to M. Monagan and an anonymous referee for





B many detailed comments and suggestions.

p p



References



[1] Carl Friedrich Gauss. Disquisitiones Arithmeticae.

p G. Fleischer Jun., Gottingen,¨ 1801. In Latin. Reprinted



in [7]. German translation: [8]; English translation: [9].



p [2] Andreas Weber. Computing radical expressions for roots

of unity. SIGSAM Bulletin, 30(117):11–20, September

p 1996.

The radsolve-function computed the 7th root of unity that [3] W. Narkiewicz. Elementary and Analytic Theory of

 I  

 Numbers. Springer-Verlag, 1990.  is equal to e :

radnormal(A-Bˆ6); [4] Lisl Gaal. Classical Galois Theory. Chelsea Publishing

Company, New York, fourth edition, 1988.

Although expression A was obtained by a special method, [5] Harold M. Edwards. Galois Theory, volume 101 of it is not simpler than the one derived by our general algo- Graduate Texts in Mathematics. Springer-Verlag, New rithm, as the cost function shows: York, 1984.

readlib(cost): readlib(optimize): [6] Richard Zippel. Computer algebra. Unpublished Lecture

cost(optimize(A)); Notes, 1994.

additions multiplications

[7] Carl Friedrich Gauss. Werke, volume I. Georg Olms

functions assignments Verlag, Hildesheim, New York, 1981. [8] Carl Friedrich Gauss. Untersuchungen uber¨ hohere¨ cost(optimize(B)); Arithmetik. Chelsea Publishing Company, second edi-

tion, 1981.

additions multiplications divisions

functions assignments [9] Carl Friedrich Gauss. Disquisitiones Arithmeticae — En- glish Edition. Springer-Verlag, 1986.

Vol. ???, No. ??, 1999 5