Using the Blankinship algorithm to find the general solution of a linear ...

4 downloads 516 Views 226KB Size Report
solution of the associated linear diophantine equation, can be used to find the general ... + a,x,=d. (1). This note calls attention to the fact that the Blankinship algorithm actually .... Center, San Diego, California, November 1975. 5. Morito, S.
Acta Informatica 13, 379-382 (1980)

In uca i

In

9 by Springer-Verlag 1980

Using the Blankinship Algorithm to Find the General Solution of a Linear Diophantine Equation Susumu Morito and Harvey M. Salkin Department of Operations Research,Case Western ReserveUniversity,Cleveland,Ohio 44106,U.S.A. Summary. This paper shows that the Blankinship algorithm, originally proposed to find the greatest common divisor of several integers and a solution of the associated linear diophantine equation, can be used to find the general solution of the equation. This yields a more efficient method to find the general solution than the one proposed by Bond. The modification of Blankinship's algorithm to avoid generating vectors with huge component values is also proposed. 1. Introduction

Blankinship [1] proposed a modified version of the well-known Euclidean algorithm to find the greatest common divisor (gcd), d, of n positive integers, al, a2 . . . . . a,. In that paper, it is also noted that the procedure finds a solution to a linear diophantine equation (1): al x a+a2x2

+ ...

+ a,x,=d.

(1)

This note calls attention to the fact that the Blankinship algorithm actually finds the general solution for the linear diophantine equation with the right hand side constant equal to zero, i.e., (2): aa x l + a 2

xz+...+a,

x,=0,

(2)

and thus the general solution for the linear diophantine equation with any right hand side which is an integer multiple of d, i.e., (3): al x l + a 2 X

2 -[- . . .

+a, xn=r=kd,

(3)

where k is any integer. It is well-known (see, e.g., [2]) that the general solution, x = ( x 1, x a, ..., x,), of (2) can be expressed as an integer linear combination of ( n - 1 ) vectors, x B~,x B2, ..., x B"-~, namely, x = k l x ~l + k 2xB2+... + k , _ l x B"-',

(4)

where k i are integers and x B' (i= 1..... n - 1 ) are 'generating' vectors, each of which satisfies (2). Bond [2] presents an algorithm, which repeatedly applies

0001-5903/80/0013/0379/$01.00

380

S. Morito and H.M. Salkin

the procedure proposed by Weinstock [7], to find a set of these ( n - 1) generating vectors. However, Bond's algorithm tends to create generating vectors having components with huge numbers in absolute value, especially when the original integers a~, az, ...,a, are large ~. This makes the Bond algorithm rather unattractive especially for computer implementation. To overcome this difficulty, we show that Blankinship's algorithm can be modified in the following two ways. First, when specifying the rule to choose a particular 'operand' (see [1, p. 743, Step 2]), and second, when selecting the 'operator' (see [1, p. 742, Step 1]). The first alteration can be made so that the algorithm produces generating vectors of the form given by Bond [2, p. 956], while the second change allows for considerably smaller elements in the generating vectors. This means that a modified version of Blankinship's procedure can be used in place of the Bond algorithm to produce computationally useful generating vectors. We now present the details of these changes.

2. The Blankinship and Bond Algorithms A listing of the Blankinship algorithm is given below. Let a = ( a t , a 2 . . . . . a,), form the n x ( n + 1) matrix [a, I]. Step 1. Denote the row with the smallest nonzero first element as the 'operator' row.

Step 2. Select any other row with a nonzero first element and call it the 'operand' row. When no operand row exists, the process terminates. Step 3. Add an integer multiple of the operator row to the operand row so that the first element of the resulting row is nonnegative and strictly less than the first element of the operator row. Return to Step 1. When the process is complete, the matrix appears as [a', M], where the vector a' has only one nonzero element which is the gcd, d, and the associated row of M corresponds to the vector x = ( x l , x 2 , ...,x,,) which satisfies (1). As we will show, the remaining n - 1 rows of M have a zero in the first column (i.e., in a') and form a set of generating vectors for (2), namely, x ~1, x ~2, ..., x B"-I. Even though this result is general for the Blankinship procedure, we specialize the algorithm by specifying the choice of the operand row in Step 2. This allows us to see the relationship between the Blankinship, Bond, and other algorithms.

Rule A. In Step 2, select the bottommost eligible row, different from the operator row, as the operand row. (This corresponds to Blankinship's remark [1, p. 744] to 'select the previous operator as the new operand'.) Using Rule A allows us to implement Bond's algorithm without using Weinstock's procedure. In particular, the modified algorithm first finds one generating vector whose nonzero components are only x , _ l and x,. As a by-product of the Blankinship algorithm, we find a solution to a,_ 1 x,_ t + a, x, = gcd (a,_ t, a,). Based on this solution, the algorithm finds a second generating vector whose 1 An important scenario requiring the solution of a linear diophantine equation is in radio frequency management [4]. In this application, the integers a~ (i = 1. . . . . n) correspond to transmit radio frequencies that have a relatively large magnitude; often, in the order of a thousand or tenthousand

The General Solution of a Linear Diophantine Equation

381

nonzero components are Xn_2, Xn_l, and x,, and the process continues until n - 1 vectors of this type are found. The modified Blankinship procedure appears superior to the one originally proposed by Bond using the Weinstock algorithm, because a solution for a , _ k X , _ k + . . . + a , x , = g c d (a,_k . . . . ,a,) is found as the by-product of the preceding computations ( k = l , 2 , . . . , n - l ) , and thus no separate use of the Weinstock algorithm is needed. In Bond's algorithm, two consecutive applications of the Weinstock algorithm are not related to each other thus making the Bond algorithm inefficient. The following alternative to Step 2 can also be considered [3]: Rule B. In Step 2, select the topmost eligible row as the operand row.

It is not immediately apparent that this modification allows the Blankinship algorithm to produce a set of generating vectors. The proof is left to [-5]. To illustrate the discussion, consider a small example with n = 3 and a = (8913, 5677, 4378). The algorithm with Rule A produces generating vectors (0, 4378, - 5 6 7 7 ) and (1, 1, 12736677, -16515789), whereas the procedure with Rule B gives (8189939, -227499, -16378578) and (989097, -27475, -1978037). In general, the application of Rule B does not reduce the size of the elements in the generating vectors.

3. A Modified Blankinship Algorithm In order to avoid having huge numbers in the generating vectors, we now modify Steps 1 and 2 as Steps 1' and 2', respectively. Step 1'. Denote the row with the largest nonzero element as the ' o p e r a n d ' row. Step 2'. Select the row with the second largest nonzero element and call it the ' o p e r a t o r ' row. When no operator row exists, the operand is the gcd and the n - 1 generating vectors are obtained, and terminate. We assume that Steps 1' and 2' are applied while no element in the first column is 0. In other words, as soon as the remainder in Step 3 becomes 0, we revert to the original Steps 1 and 2 with Rule A instead of Steps 1' and 2', respectivelyl If we apply the algorithm with Steps 1' and 2' to the previous example immediately prior to the remainder in Step 3 becoming 0, we have the following matrix: [a'M]-

- 19 -15

36 -42

-

(5) 85/"

As Blankinship noted, the gcd (8913, 5677, 4378) is equal to the gcd (2, 1, 1). Moreover, there is a one-to-one correspondence between solutions, x and y, of the two diophantine equations (2') and (7): 8913x 1 + 5677x 2 + 4378x 3 = 0, 2Y1+

Y2+

Y3 = 0 .

(2') (7)

382

S. Morito and H.M. Salkin

The coefficients of (7), namely, (2, 1, 1), correspond to the first column of (5), i.e., a'. In fact, the exact correspondence between x and y is given by

x=My=

19 15

36 -42

y.

(8)

85/

But the absolute value of the determinant of the matrix M is 1. (To see this, note that we start the c o m p u t a t i o n s from the identify matrix, and that each iteration corresponds to premultiplying the columns of [a', M ] by a matrix M ' whose determinant has absolute value of 1.) Thus since it is well k n o w n (see, e.g. [6]) that if there exists a matrix M such that x = M y with Idet MI = 1, then there is a one-to-one correspondence between the solutions of x and y, it follows that, if yB1, .... y~" I are generating vectors of (7), then M y 8~, . . . , M y 8" ~ are generating vectors of (2'). Therefore, we apply the Blankinship algorithm with Rule A to (7), rather than to (2'), to find the generating vectors of (7), which can be converted into the generating vectors of (2'). In actual computations, there is no need to explicitly consider y, as we only have to deal with the matrix M. We add that the observations given in this section apply to any variants to the Blankinship algorithm. The procedure given here would produce (53, 61, - 1 8 7 ) and (4, - 7 8 , 93) as generating vectors for (2'). C o m p a r i n g this generating set with the ones given in Section 2 indeed indicates dramatically smaller components.

Remarks. (1) Step 3 of any variant of Blankinship algorithm can generally be m a d e m o r e efficient by considering the least absolute remainder in the normal Euclidean algorithm rather than the positive remainder. (2) The generating vectors can be obtained by using Steps 1' and 2' all through the algorithm, rather than switching to the standard Blankinship algorithm with Rule A. However, the p r o o f of this is somewhat more complicated and is given in [5] in a m o r e general framework. Acknowledgement: Part of this work was supported by the Office of Naval Research under contract Number N00014-67-A-0404-0010. References 1. Blankinship, W.A.: A new version of the Euclidean algorithm. Amer. Math. Monthly 70, 742-745 (1963) 2. Bond, J.: Calculating the general solution of a linear diophantine equation. Amer. Math. Monthly 74, 955-957 (1967) 3. Bradley, G.: Algorithm and bound for the greatest common divisor of n integers, Comm. of ACM 13, 433-436 (1970) 4. Chase, W.: The indirect threat algorithm, Technical memorandum, Naval Electronics Laboratory Center, San Diego, California, November 1975 5. Morito, S., Salkin, H.M.: Finding the general solution of a linear diophantine equation, Technical memorandum No. 429, Department of Operations Research, Case Western Reserve University, Cleveland, Ohio, September 1977 6. Salkin, H.M.: Integer programming, p. 314, Reading, Mass: Addison-Wesley 1975 7. Weinstock, R.: Greatest common divisor of several integers and an associated linear diophantine equation, Amer. Math. Monthly 67, 664-667 (1960) Received May 16, 1978

Suggest Documents