Quick Review Using the Gaussian Trick and Euclid’s Algorithm to solve linear congruences As examples, we will use the questions from homework #5. First, the Gaussian trick. The first step is to divide both sides of the congruence (not the modulus!) by the coefficient of X: 21X ≡ 1 (mod 92) X ≡ 1/21 Next, we subtract the modulus from the numerator of the resulting fraction, as shown: X ≡ (1 – 92)/21 X ≡ -91/21 Finally, we keep subtracting the modulus until we obtain an integer result. For example, in this problem we must subtract 92 a total of six times before we obtain an integer result. If it is possible to reduce a fraction along the way, we can do so (here –459/21 was reduced to -153/7) and then resume subtracting the modulus if the result is not yet an integer. Note that you can still obtain a valid result even if you do not choose to reduce fractions. –91/21 can be reduced to –13/3, which would have yielded the result of –35 after only one more subtraction of 92; but we still converge to the correct answer eventually without reducing the fraction. It just takes more iterations. ≡ -91/21 ≡ -183/21 ≡ -275/21 ≡ -367/21 ≡ -459/21 = -153/7 ≡ -245/7 = -35 Eventually, we end up with –35. But we do not want a negative result, so we re-add the modulus to obtain a value in the range of 0 < x < 92: x = -35 + 92 = 57. You can verify that 21*57 will produce a remainder of 1 when divided by 92. Second Gaussian Trick example 15X ≡ 2 (mod 49) X ≡ 2/15 ≡ (2 – 49)/15 ≡ -47/15 X ≡ -96/15 = -32/5 ≡ -81/5 ≡ -130/5 = -26 but 0 < x < 49, so x = -26 + 49 = 23. Euclid’s Algorithm Euclid’s algorithm is an iterative process that requires rewriting each previous step in terms of a new variable. Solving a linear congruence using Euclid’s Algorithm can be quite lengthy and tedious, so it is important to check over your work carefully. First, we rewrite the congruence according to its definition: 27X ≡ 1 (mod 8) is equivalent to saying 27x = 8y + 1 That is, 27 multiplied by x will yield some multiple of 8 plus 1. Or, when you divide 27x by 8y, you will get a remainder of 1. Next, we solve for y in the previous equation: y = (27x – 1)/8 In the last step of the iteration, we want to create separate terms on the right side of the expression. We divide 8 into each term (27x –1) and obtain the following: y = 3x + (3x – 1)/8 Another way of looking at this expression is, 27x –1 is equivalent to 24x + 3x –1; but if we divide 24x by 8, we get 3x. (3x –1) is not divisible by 8, so we leave it as it is and keep the 8 in the denominator. The goal of this algorithm is to obtain a remainder (that is, the term with a denominator unequal to 1) for which some positive, integer value of the variable in the numerator will cause the numerator to be divisible by the denominator. In this case, we are able to do so in the first iteration by setting x equal to 3: 8|(3x – 1) x = 3 and we have an immediate solution. Consider a second example, however, where additional iterations are necessary: Second Euclid’s Algorithm example 15X ≡ 2 (mod 49) 15X = 49y + 2 y = (15x –2)/49 Here is where the next iteration comes in. We cannot divide 49 into 15 even once, so we work with the fraction as it is. What we are trying to do is find a value of x for which (15x-2)/49. Another way of saying this is 15x –2 = 49t Where t is some integer we have introduced as a new variable. In other words, we want (15x –2) to be a multiple of 49. Now we continue with our iteration. We solve for the variable from the previous step (in this case, x) X = (49t + 2)/15 49 can be divided 3 times by 15, with a remainder of 4, so we write X = 3t + (4t + 2)/15 Now we can find a value of t for which the fractional portion of the equation is equal to an integer. If we set t=7, we’ll have (4*7 + 2)/15 = 30/15 = 2. Here’s the trick: our answer isn’t 7; that’s just the value of our latest new variable. To find a valid integer value for x, we need to work backwards through our algorithm: X = (49t + 2)/15 = (49*7 + 2)/15 = (343 + 2)/15 = 23. As you can see, this is the same answer we obtained using the Gaussian Trick. One last Euclid’s Algorithm example (the infamous trick question) 18X ≡ 3 (mod 6) There’s no point trying to use Euclid’s Algorithm to obtain a unique solution to this congruence, in order for a unique solution to exist, the coefficient of X and the modulus must be relatively prime. GCD (18,6) 1; therefore no unique solution exists. (Many solutions exist!)