Sunteți pe pagina 1din 7

The Berlekamp-Massey Algorithm revisited

Nadia Ben Atti (), Gema M. DiazToca () Henri Lombardi ()

Abstract We propose a slight modication of the Berlekamp-Massey Algorithm for obtaining the minimal polynomial of a given linearly recurrent sequence. Such a modication enables to explain it in a simpler way and to adapt it to lazy evaluation.

MSC 2000: 68W30, 15A03 Key words: Berlekamp-Massey Algorithm. Linearly recurrent sequences.

Introduction: The usual Berlekamp-Massey algorithm


i=0

Let K be an arbitrary eld. Given a linearly recurrent sequence, denoted by S(x) =


d i=0 d i=0

ai xi , ai

K, we wish to compute its minimal polynomial, denoted by P (x). Recall that if P (x) is given by P (x) = pi xi denotes such polynomial, then P (x) is the polynomial of the smallest degree such that

pi aj+i = 0, for all j in N.

Let suppose that the minimal polynomial of S(x) has degree bound n. Under such hypothesis, the Berlekamp-Massey Algorithm only requires the rst 2n coecients of S(x) in order to compute the minimal polynomial. Such coecients dene the polynomial S = 2n1 ai xi . i=0 A large literature can be consulted nowadays in relation to the Berlekamps Algorithm. The (original) Berlekamps Algorithm was created for decoding Bose-Chaudhuri-Hocquenghem (BCH) codes in 1968 (see [1]). One year later, the original version of this algorithm has been simplied by Massey (see [5]). The similarity of the algorithm to the extended Euclidean Algorithm can be found in several articles, for instance, in [2],[3], [6], [9] and [10]. Some more recent interpretations of the BerlekampMassey Algorithm in terms of Hankel Matrices and Pad approximations can be found in [4] and e [7]. The usual interpretation of the Berlekamp-Massey Algorithm for obtaining P (x) is expressed in pseudocode in Algorithm 1. In practice, we must apply the simplication of the extended Euclidean Algorithm given in [3], to nd exactly the Berlekamp-Massey Algorithm. Such simplication is based on the fact that initial R0 is equal to x2n . Although Algorithm 1 is not complicated, it seems to be no easy to nd a direct and transparent explanation for the determination of the degree of P . In the literature, we think there is a little confusion with the dierent denitions of minimal polynomial and with the dierent ways of dening
Equipe de Mathmatiques, CNRS UMR 6623, UFR des Sciences et Techniques, Universit de Franche-Comt, 25 e e e 030 Besanon cedex, France. nadia.benatti@ensi.rnu.tn c Dpto. de Matematicas Aplicada. Universidad de Murcia, Spain. gemadiaz@um.es, partially supported by the Galois Theory and Explicit Methods in Arithmetic Project HPRN-CT-2000-00114 Equipe de Mathmatiques, CNRS UMR 6623, UFR des Sciences et Techniques, Universit de Franche-Comt, e e e 25 030 Besanon cedex, France, lombardi@math.univ-fcomte.fr, partially supported by the European Union funded c project RAAG CT-2001-00271

Algorithm 1 The Usual Berlekamp-Massey Algorithm Input: n N. The rst 2n coecients of a linearly recurrent sequence dened over K, given by the list [a0 , a1 , . . . , a2n1 ]. The minimal polynomial has degree bound n. Output : The minimal polynomial P of the sequence. Start Local variables : R, R0 , R1 , V, V0 , V1 , Q : polynomials in x # initialization 2n1 R0 := x2n ; R1 := i=0 ai xi ; V0 = 0 ; V1 = 1 ; # loop while n deg(R1 ) do (Q, R) := quotient and remainder of R0 divided by R1 ; V := V0 Q V1 ; V0 := V1 ; V1 := V ; R0 := R1 ; R1 := R ; end while # exit d := max(deg(V1 ), 1 + deg(R1 )) ; P := xd V1 (1/x) ; Return P := P/leadcoe(P ). End.

the sequence. Here, we introduce a slight modication of the algorithm which makes it more comprehensible and natural. We did not nd in the literature such a modication before the rst submission of this article (May 2004). However, we would like to add that you can also nd it in [8], published in 2005, without any reference.

Some good reasons to modify the usual algorithm

By the one hand, as it can be observed at the end of Algorithm 1, we have to compute the (nearly) reverse polynomial of V1 , in order to obtain the right polynomial. The following example helps us to understand what happens: n = d = 3, S = a0 + a1 x + a2 x2 + a3 x3 + a4 x4 + a5 x5 = 1 + 2x + 7x2 9x3 + 2x4 + 7x5 , Algorithm 1(3, [1, 2, 7, 9, 2, 7]) P = x + x2 + x3 , with V1 = v0 + v1 x + v2 x2 = 49/67(1 + x + x2 ), and R such that S V1 = R mod x6 , deg(R) = 2 which implies that coe(S V1 , x, 3) = a1 v2 + a2 v1 + a3 v0 = 2v2 + 7v1 9v0 = 0, coe(S V1 , x, 4) = a2 v2 + a3 v1 + a4 v0 = 7v2 9v1 + 2v0 = 0, coe(S V1 , x, 5) = a3 v2 + a4 v1 + a5 v0 = 9v2 + 2v1 + 7v0 = 0. Hence, the right degree of P is given by the degree of the last R1 plus one because x divides P . Observe that a0 v2 + a1 v1 + a2 v0 = 490/67 = 0. We would like to obtain directly the desired polynomial from V1 . Moreover, by the other hand, in Algorithm 1 all the rst 2 n coecients are required to start the usual algorithm, where n only provides a degree bound for the minimal polynomial. Consequently, it may be possible that the true degree of P is much smaller that n and so, less coecients of the sequence are required to obtain the wanted polynomial. So, we suggest a more natural, ecient and direct way to obtain P . Our idea is to consider the polynomial S = 2n1 ai x2n1i as the initial R1 . Observe that in this case, using the same notation i=0

as in Algorithm 1, the same example shows that it is not necessary to reverse the polynomial V1 at the end of the algorithm. n = d = 3, S = a0 x5 + a1 x4 + a2 x3 + a3 x2 + a4 x + a5 = x5 + 2 x4 + 7 x3 9 x2 + 2 x + 7, Algorithm 2 (3, [1, 2, 7, 9, 2, 7]) P = x + x2 + x3 , with V1 = v0 + v1 x + v2 x2 + v3 x3 = 9/670(x + x2 + x3 ), and R such that S V1 = R mod x6 , deg(R) = 2 which implies that coe(S V1 , x, 3) = a2 v0 + a3 v1 + a4 v2 + a5 v3 = 9v1 + 2v2 + 7v3 = 0, coe(S V1 , x, 4) = a1 v0 + a2 v1 + a3 v2 + a4 v3 = 7v1 9v2 + 2v3 = 0, coe(S V1 , x, 5) = a0 v0 + a1 v1 + a2 v2 + a3 v3 = 2v1 + 7v2 9v3 = 0. Furthermore, when n deg(P ), the algorithm can admit a lazy evaluation. In other words, the algorithm can be initiated with less coecients than 2n and if the outcome does not provide the wanted polynomial, we increase the number of coecients but remark that it is not necessary to initiate again the algorithm because we can take advantages of the computations done before. We will explain this application of the algorithm in Section 3. Next, we introduce our modied Berlekamp-Massey Algorithm in pseudocode (Algorithm 2): Algorithm 2 Modied Berlekamp-Massey Algorithm Input: n N. The rst 2n coecients of a linearly recurrent sequence dened over K, given by the list [a0 , a1 , . . . , a2n1 ]. The minimal polynomial has degree bound n. Output : The minimal polynomial P of the sequence. Start Local variables : R, R0 , R1 , V, V0 , V1 , Q : polynomials in x ; m = 2n 1 : integer. # initialization m := 2n 1 ; R0 := x2n ; R1 := m ami xi ; V0 = 0 ; V1 = 1 ; i=0 # loop while n deg(R1 ) do (Q, R) := quotient and remainder of R0 divided by R1 ; V := V0 Q V1 ; V0 := V1 ; V1 := V ; R0 := R1 ; R1 := R ; end while # exit Return P := V1 /lc(V1 ); End. Now we prove our result. Let a = (an )nN be an arbitrary list and the following Hankel matrix of order r p, ai ai+1 ai+2 . . . ai+p1 ai+1 ai+2 ai+p ai+2 a Hi,r,p = . . . . . . ai+r1 ai+r . . . . . . ai+r+p2 i, r, p N. Let Hi,r,p denote
a

and let Pa (x) be the minimal polynomial of a. The next proposition shows the well known relation between the rank of Hankel matrix and the sequence.

Proposition 1 Let a be a linearly recurrent sequence . If a has a generating polynomial of degree n, then the degree d of its minimal polynomial Pa is equal to the rank of the Hankel matrix a0 a1 a2 an2 an1 . a1 .. an1 an a2 . . . . . . a2 .. .. . . a . H0,n,n = . . . . . . . . . .. .. . . an2 an1 a2n2 a2n1 an1 an a2n1 a2n2 The coecients of Pa (x) = xd system that is, a0 a1 a2 . . . ad1 ad1 . .. ad . . .. . .. . . . .. ... . . . ad a2d2 a1 a2 a2 g0 g1 g2 . . . gd1 = ad ad+1 ad+2 . . . a2d1 . (1)
d1 i i=0 gi x

K[x] are provided by the unique solution of the linear


a a

H0,d,d G = Hd,d,1 ,

As an immediate corollary of Proposition 1, we have the following result. Corollary 2 Using the notation of Proposition 1, a vector Y = (p0 , . . . , pn ) is solution of H0,n,n+1 Y = 0, that is, a0 a1 a2 an1 an . a1 .. a2 an an+1 . . . . . . a2 .. .. . . . . . . .. . . . .. . . . . an1 an a2n2 a2n1 if and only if the polynomial P (x) =
n i i=0 pi x a

p 0 p1 p2 . . . pn1 pn

=0

(2)

K[x] is multiple of Pa (x).

Proof. a By Proposition 1 the dimension of Ker(H0,n,n+1 ) is n d. For 0 j n 1, let Cj denote the a a jth column of H0,n,n+1 , that is Cj = Hj,n,1 = [aj , aj+1 , . . . , an+j1 ]t . Since Pa (x) is a generating polynomial of a, for d j n 1, we obtain that Cj
j1 i=jd

gij+d Ci = 0.

Thus the linear independent columns [g0 , . . . , gd1 , 1, 0, . . . , 0]t , . . . , [0, . . . , 0, g0 , . . . , gd1 , 1]t dea a ne a basis of Ker(H0,n,n+1 ). Therefore, Y = (p0 , . . . , pn ) veries H0,n,n+1 Y = 0 if and only if the polynomial P (x) = n pi xi is a multiple of Pa (x). i=0 If we consider m = 2n 1 and S =
m i i=0 ami x ,

by applying Equation (2) we obtain: (3)

R, U K[x] such that deg(R) < n, deg(P ) n and P (x)S(x) + U (x)x2n = R(x).

Hence, it turns out that nding the minimal polynomial of a is equivalent to solving (3) for the minimum degree of P . Moreover, its well known that

the extended Euclidean Algorithm, with x2n and S, provides an equality as (3) when the rst remainder of degree smaller than < n is reached. Let denote such remainder by Rk , if we consider other polynomials P (x), U (x) and R (x) such that P (x)S(x) + U (x)x2n = R (x) and deg(R ) < deg(Rk1 ), then deg(P ) deg(P ) and deg(U ) deg(U ). That proves that our modication of Berlekamp-Massey Algorithm is right.

Lazy Evaluation

Our modied Berlekamp-Massey Algorithm admits a lazy evaluation, which may be very useful in solving the following problem. Let f (x) K[x] be a squarefree polynomial of degree n. Let B be the universal decomposition algebra of f (x), let A be a quotient algebra of B and a A. Thus, A is a zerodimensional algebra given by A K[X1 , . . . , Xn ]/ f1 , . . . , fn , where f1 , . . . , fn dene a Grbner basis. Our aim is to compute the minimal polynomial of a, or o at least, one of its factors. However, the dimension of A, denoted by m, over K as vector space is normally too big to manipulate matrices of order m. Therefore, we apply the idea of Wiedemanns Algorithm, by computing the coecients of a linearly recurrent sequence, at = (xt ), where is a linear form over A. Moreover, since the computation of xt is usually very expensive and the minimal polynomial is likely to have degree smaller than the dimension, we are interested in computing the smallest possible number of coecients in order to get the wanted polynomial. Hence, we rst choose l < m. We start Algorithm 2 with l and [(x0 ), . . . , (x2l1 )] as input, obtaining a polynomial as a result. Now, we test if such a polynomial is the minimal one. If this is not the case, we choose again another l , l < l m, and we repeat the process with 2l coecients. However, in this next step, it is possible to take advantages of all the quotients computed before (with the exception of the last one), such that Euclidean Algorithm starts at R0 = U0 x2l +V0 and R1 = U1 x2l + V1
2l 1 i=0 2l 1 i=0

((x2l 1i )xi )

((x2l 1i )xi ), where U0 , V0 , U1 and V1 are Bezout coecients computed

in the previous step. Manifestly, repeating this argument again and again, we obtain the minimal polynomial. The following pseudocode tries to facilitate the understanding of our lazy version of BerlekampMassey Algorithm. Obviously, the choice of l is not unique. Here we have started at l = m/4, adding two coecients in every further step. In practice, the particular characteristics of the given problem could help to choose a proper l and the method of increasing it through the algorithm. Of course, the simplication of the Euclidean Algorithm in [3] must be considered to optimize the procedure.

Algorithm 3 The lazy Berlekamp-Massey Algorithm (in some particular context) Input: m N, C Kn , G: Grbner basis, a A. The minimal polynomial has degree bound m. o Output : The minimal polynomial P of a Start Local variables : l, i: integers, R, R1 , R0 , R1 , V, V1 , V0 , V1 , U, U1 , U0 , U1 , S0 , S1 , Q : polynomials in x, L, W :lists, validez; # initialization l = m/4 ; L := [1, a]; W := [1, Value(a, C)]; S0 := x2l ; S1 = W [1] x2l1 + W [2] x2l2 ; # loop for i from 3 to 2l do L[i] := normalf(L[i 1]a, G); V [i] := Value(L[i], C); S1 = S1 + V [i]x2li ; end for R0 := S0 ; R1 := S1 ; V0 = 0 ; V1 = 1 ; U0 = 1 ; V1 = 0; # loop while l deg(R1 ) do (Q, R) := quotient and remainder of R0 divided by R1 ; V := V0 QV1 ; U := U0 QU1 ; U1 := U0 ; V1 := V0 ; V0 := V1 ; V1 := V ;U0 := U1 ; U1 := U ; R0 := R1 ; R1 := R ; end while validez:=Subs(x = a, V1 ); # loop while validez = 0 do l := l + 1; # loop for i from 2l 1 to 2l do L[i] := normalf(L[i 1]a, G); W [i] := Value(L[i], C); end for S0 = x2 S0 ; S1 = x2 S1 + W [2l 1]x + W [2l]; R0 := U1 S0 + V1 S1 ; R1 := U0 S0 + V0 S1 ; U1 := U0 ; V1 := V0 ; U0 := U1 ; V0 := V1 ; # loop while l deg(R1 ) do (Q, R) := quotient and remainder of R0 divided by R1 ; V := V0 QV1 ; U := U0 QU1 ; U1 := U0 ; V1 := V0 ; V0 := V1 ; V1 := V ;U0 := U1 ; U1 := U ; R0 := R1 ; R1 := R ; end while validez:=Subs(x = a, V1 ) end while # exit Return P := V1 /leadcoe(P ). End.

References
[1] E.R. Berlekamp, Algebraic Coding Theory, McGraw-Hill, New York, ch. 7 (1968). [2] U. Cheng, On the continued fraction and Berlekamps algorithm, IEEE Trans. Inform. Theory, vol. IT-30, 54144 (1984).

[3] J.L. Dornstetter, On the equivalence Between Berlekamps and Euclids Algorithm, IEEE Trans. Inform. Theory, vol. IT-33, no 3,428431 (1987). [4] E. Jonckheere and C. Ma, A simple Hankel Interpretation of the BerlekampMassey Algorith, Linear Algebra and its Applications 125, 6576 (1989). [5] J.L. Massey, Shift register synthesis and BCH decoding, IEEE Trans. Inform. Theory, vol. IT-15, 122127 (1969). [6] W.H. Mills, Continued Fractions and Linear Recurrences, Math. Comput. 29, 173180 (1975). [7] V. Pan, New Techniques for the Computation of linear recurrence coecients, Finite Fields and Their Applications 6, 93118 (2000). [8] V. Shoup, A Computational Introduction to Number Theory and Algebra, Cambridge University Press (2005). [9] Y. Sugiyama et al. A method for solving key equation for decoding Goppa codes, Infor. Contr. vol 27, 8799 (1975). [10] L.R. Welch and R.A. Scholtx, Continued fractions and Berlekamps algorithm, IEEE Trans. Inform. Theory, vol. IT-25, 1827 (1979).

S-ar putea să vă placă și