0

To solve the following equation $$32x - 18y = 40$$, I first found the GCD like that: $$32 = (-18)(-1) + 14 $$ $$-18 = (14)(-1) - 4 $$ $$14 = (-4)(-3) + 2 $$ $$-4 = (2)(-2) + 0 $$

Therefore, I found 2. But these negative values are confusing, because I don't know if they are allowed there, even though I can find a solution to the equation if I proceed with the calculations:

$$ 2 = (14) - (-4)(-3) $$ $$ 2 = (14) - (-18-14(-1))(-3) $$ $$ 2 = (14) - 18(3)+14(3) $$ $$ 2 = (32-(-18)(-1)(4)) - (18)(3) $$ $$ 2 = 32(4) - (-18)(-4) - (18)(3) $$ $$ 2 = 32(4) - (18)(7) $$ $$ 40 = 32(80) - (18)(140) $$ Therefore, I have $$x_0 = 80, y_0 = 140$$ as particular solution, and $$x = 80 + 9n, y = 140 + 16n, n \in \mathbb{Z}$$ as a complete solution.

Bill Dubuque
  • 272,048
Jonas
  • 307
  • 1
    Yes, you can use least magnitude (possibly negative) remainders in the extended Euclidean algorithm, e.g. see the Remark here in the linked dupe. This can halve the number of steps. Another great optimization is to stop doing it backwards and instead use the easier forward method described there (or - even quicker - the fractional method described there). – Bill Dubuque Dec 10 '22 at 21:05
  • 1
    Generally we can use any gcd mod reduction steps, i.e. $(a,b) = (a' ,b),\ {\rm if},\ a\equiv a '\pmod{! b},,$ as long as they eventually reach a "simpler" gcd, where simpler need not necessarily mean smaller magnitude argument, e.g here is an increasing step $,(319,705) = (319,\color{#c00}{319+705}) = (319,\color{#c00}{2^{10}}) = 1.\ \ $ – Bill Dubuque Dec 10 '22 at 21:13
  • 1
    e.g. $!\bmod 18!:\ x \equiv \dfrac{40}{32}!!\overset{\div,2!}\iff! \bmod 9!:\ x \equiv \dfrac{20}{16}\equiv \dfrac{10}{8}\equiv \color{#c00}{\dfrac{1}{-1}},,$ so $,x = \color{#c00}{-1}+9k,,$ so $, y = \dfrac{-40+32x}{18} = \dfrac{-72+32(9k)}{18} = -4+16k.,$ Your solution shifts the parameter $, k = 9+n.\ \ $ – Bill Dubuque Dec 10 '22 at 21:43
  • 1
    Easier: $,8\mid 18y\Rightarrow 4\mid y,$ so cancel $4\Rightarrow 8x-18(y/4)=10,$ with obvious root $,x=-1=y/4\ \ $ – Bill Dubuque Dec 10 '22 at 22:35

0 Answers0