2

I have an equation like this:

$$64r+102s=2$$

And so, using the extended Euclidean algorithm, I did such calculations:

$$102=64⋅1+38 \\ 64=38⋅1+26\\ 38=26⋅1+12\\ 26=12⋅2+2\\ 12=2⋅6+0 $$

Which led me to:

$$0=12-2⋅6=12-6⋅(26-12⋅2)=13⋅12-6⋅26=13⋅(38-26)-6⋅26=13⋅38-19⋅26=13⋅38-19⋅(64-38)= 32⋅38-19⋅64=32⋅(102-64)-19⋅64= -51⋅64+32⋅102$$

And here's when I get stuck. I can't find an error anywhere in the last part while it would imply that $r=-51\cdot\frac{2}{2}-\frac{102}{2}m=-51-51m$ which is not the correct answer. Could someone please tell where did I make a mistake?

Straightfw
  • 1,558

2 Answers2

2

There is a way that is less error-prone, and it uses tables

Index $i$Quotient $q_{i-1}$      Remainder $r_i$         $x_i$                 $y_i$                   
$0$                         $102$                 $1$                 $0$                     $1$                         $64$                  $0$                 $1$                     $2$      $102\div64=1$       $102-64=38$      $1-1\times0=1$      $0-1\times1=-1$       $3$      $64\div38=1$        $64-38=26$       $0-1\times1=-1$    $1-1\times-1=2$        $4$      $38\div26=1$        $38-26=12$       $1-1\times-1=2$    $-1-1\times2=-3$      $5$      $26\div12=2$        $26-2\times12=2$    $-1-2\times2=-5$   $2-2\times-3=8$        $6$      $12\div2=6$         $12-6\times2=0$     $2-6\times-5=32$    $-3-6\times8=-51$    

Where it can easily be seen that $\gcd(102,64)=2$ which is the last non-zero remainder and $-5\times102+8\times64=2$.

If you want to find all solutions of this Linear Diophantine Equation, then use the following formula: $r=r_0-51n$ and $s=s_0+32n$. That is, $\forall n \in \mathbb{Z}$ and where $r_0=8$ $s_0=-5$

Side note: if you "factor" this equation, you get $32r+51s=1$, then:

$8\times32\equiv1\pmod{51}$

$256\equiv1\pmod{51}$

In fact, $256=5\times51+1$

EDIT: THE SECOND MODULAR MULTIPLICATIVE INVERSE:

$-5\times51\equiv1\pmod{32}$

This can be thought of as:

$-255\equiv-31\pmod{32}$

Adding $32$ is the same as not doing anything at all when working in $\mathbb{Z}_{32}$ and therefore

$-255\equiv1\pmod{32}$

Another way to think about this is $-255-1\equiv0\pmod{32}$, which implies

$-256\equiv0\pmod{32}$

In fact, $-256=32\times-8$

Hope this helps!

user2213307
  • 173
  • 1
  • 9
  • Oh my god, I cannot believe how bad my answer looks in Internet Explorer 11 under Windows 8.1, having used Firefox in Ubuntu to make my answer and looks perfect! Damn you, StackExchange. – user2213307 Dec 01 '13 at 05:04
1

You started in the wrong place. You want to express $2$ as an integer combination of $64$ and $102$, not $0$, so you should start with $2=26-2\cdot12$:

$$\begin{align*} 2&=26-2\cdot12\\ &=26-2(38-26)\\ &=3\cdot26-2\cdot38\\ &=3(64-38)-2\cdot38\\ &=3\cdot64-5\cdot38\\ &=3\cdot64-5(102-64)\\ &=8\cdot64-5\cdot102 \end{align*}$$

Brian M. Scott
  • 616,228