0

I'd like to know how to solve these using euclid. I have checked some videos on youtube but I either didn't understand them or it was done without euclid.. If there is exact same question, please post link and excuse for duplication. I will delete this instantly then.

I have chosen an example: $135x+112y=6649$

So using euclid:

$$135=112 \cdot 1+23$$

$$112=23 \cdot 4+20$$

$$23=20 \cdot 1+3$$

$$20=3 \cdot 6+2$$

$$3=2 \cdot 1+1$$

$$2=1 \cdot 2+0$$

Alright so here we are at the end of euclid and actually here should begin the exciting part but sadly I don't know how to continue here -.-

I saw some kind of table was used with the values I got so far from euclid..?

If my example is badly chosen then please maybe choose an easier / smaller one so better for explain?

cnmesr
  • 4,720
  • 7
  • 44
  • 83

2 Answers2

4

So, I guess you would like to solve linear diophantine equations(LDE) in two variables. Alright, so here is the recipe. First, we would like to know whether the equation $ax+by=c$ is solvable or not. A necessary and sufficient condition is established by Bezout's Lemma (see Wikipedia) which states that if the $\gcd(a,b)|c$ then the equation $ax+by=c$ has solutions. This should make sense right, I mean if I write something like $4x+2y=3,$ then you can factor out the $2$ and claim that $2(2x+y)=3\Rightarrow 2|3$ which is absolute nonsense. Next, we would like to know how many solutions there are to the LDE. In general if $d=\gcd(a,b)$ then there are $d$ mutually incongruent solutions to the LDE.

Now how do we get those solutions? Well, this is where Euclid's Algorithm comes to the rescue. Often you'll find that it is easy to guess a solution to an LDE by inspection, for example, if I ask you to solve $3x-2y=1$, you'll right away claim that $x=1,y=1$ satisfy this equation. On the other hand, complicated equations involving large coefficients (like the one you've mentioned) require more than inspection. In cases where a particular solution cannot be obtained by inspection, we use Euclid's Algorithm.

We first find a particular solution using Euclid's Algorithm say $(x_0,y_0)$ and in order to obtain a general solution to the LDE we write that $x=x_0+\frac{b}{d}t$ and $y=y_0-\frac{a}{d}t$, where $d=\gcd(a,b)$ and $t$ is an integer. You can verify this as follows: We began with the claim that $ax_0+by_0=c$, then if we replace $x$ and $y$ by the general solutions we get:$$a(x_0+\frac{b}{d}t)+b(y_0-\frac{a}{d}t)=ax_0+by_0+\frac{ab}{d}t-\frac{ba}{d}t=c.$$ Voilà! we've got the general solution of the LDE.

I am guessing that you might also have a problem with obtaining the particular solution from Euclid's Algorithm: Well the way we do it as follows- Say we have the LDE $$18x+189y=81$$ and we would like to obtain a particular solution since its hard to guess by inspection. So we first write divide both sides $9$ or in general by the gcd (which is always possible by Bezout's Lemma if the LDE is solvable) and hence we obtain $2x+21y=9.$ Now $21=2*10+1$ and so $21(1)+2(-10)=1$ and so $21(9)+2(-90)=9\Rightarrow 18(-90)+189(9)=81$ and there you have it $x_0=-90$ and $y_0=9$ by Euclid's Algorithm.

P. Ewald
  • 162
Student
  • 9,196
  • 8
  • 35
  • 81
1

Using your second last equation, we get $1=3-2$. Both $2$ and $3$ are remainders in other equations, so you can replace them by $20-3\cdot6$ and $23-20$, respectively. Keep replacing incidences of remainders with their equivalents from higher-up equations, until you have a linear combination of $135$ and $112$ which equals one. Then multiply the whole bit by $6649$. That gives one solution, $(x_0,y_0)$. The general solution is $x=x_0 + 112t, y=y_0-135t$ where $t$ ranges over the integers.

  • If I do what you say, I get at the end: $$1=-47 \cdot 112 + 39 \cdot 135$$ I know I did it correctly till here because checked with online calculator the multiplicative inverse which is in deed $39$. But what can I do with this now? – cnmesr Nov 17 '16 at 21:29
  • Then you have $6649 = (-47\cdot 6649)112+(39\cdot 6649) 135$, so you have one solution. If you add $135t$ to $-47\cdot 6649$ and subtract $112t$ from $39\cdot 6649$, for any $t$, you will get another solution. It's not too hard to work out which $t$ will give you small solutions. – B. Goddard Nov 17 '16 at 21:39
  • 1
    @cnmesr You can avoid the tedious error-prone back-substitution in the extended Euclidean algorithm by instead using this more convenient version of the algorithm. – Bill Dubuque Nov 17 '16 at 21:54