-1

Please explain me how to compute the coefficients of Bezout's lemma with the help of an example.

Also, if I develop an algorithm to find all prime numbers which performs one operation to find Bezout's coefficients, one modulo operation and one multiplication operation to find each successive prime, will it be a good discovery ?

2 Answers2

3

I use an answer I gave to another question on Bézout's identity with some more details:

As an example, let's take $a=4258$, $b=147$.

Let's start with $r_0=4258, r_1=147$. If $q_i$ is the quotient and $r_{i+1} $ is the remainder at the $i$-th step (dividing $r_{i-1}$ by $r_i$), we have: $$r_{i-1}=q_ir_i+r_{i+1} $$ whence: $$r_{i+1}=r_{i-1}-q_ir_i$$

Claim: each remainder in the euclidean algorithm satisfies Bézout's identity.

Indeed, a simple induction shows that, if we write $r_i=u_i\cdot 4258+v_i\cdot 147$, the algorithm translates into the relations: $$u_{i+1}=u_{i-1}-q_iu_i,\qquad v_{i+1}=v_{i-1}-q_iv_i$$ These relations allow for computing progressively all Bézout's coefficients without having to revert back. This is the Extended Euclidean Algorithm. Here is how it goes in the present case:

$$ \begin{array}[t]{r@{\qquad}r@{\qquad}r@{\qquad}r} r_i &u_i &v_i & q_i\\ \hline 4258 & 1 & 0 & \\ 147 & 0 & 1 & 28\\ \hline 142 & 1 & -28 & 1\\ 5 & -1 & 29 & 28 \\ 2 & 29 & -840 & 2 \\ 1 & -59 & 1709 &\color{red}2 \\ \hline \color{red}0& \color{red}{147} & \color{red}{-4258} \end{array} $$

So $-59\times4258+1709\times 147=1$.

Note that, if you proceed one step further (in red), you obtain integers $u,v$ such that $u\cdot 4258+v\cdot147=0$, i.e. $\lvert u\cdot 4258\rvert=\lvert v\cdot147\rvert= \operatorname{lcm}(4258,147)$ – not really interesting here, as $147$ and $4258$ are coprime, but might be interesting in other cases.

Bernard
  • 175,478
2

I'm addressing your first question, so to speak:

As already stated by anon, you can find the Bezout coefficients using the extended euclidean algorithm and yes, it's "fast". Here is one version of it, that avoids "back-substitution":

Given are (let's say natural) numbers $a,b$ with $a> b$. Start with a table like this:

EuclidianAlgorithmInit

Then compute further entries by:

$$q_i = \text{floor}(z_{i-1}/z_i) \text{ for } i\geq 1$$

and:

$$x_{i+1} = x_{i-1}-q_ix_i$$ $$y_{i+1} = y_{i-1}-q_iy_i$$ $$z_{i+1} = z_{i-1}-q_iz_i$$

Here, $\text{floor}(x)$ is the greatest integer less then $x$.

There is an $I$, s.t. $z_{I+1} = 0$ (the algorithm terminates). Then:

$$z_I = x_I \cdot a + y_I \cdot b = \gcd(a,b)$$ So $x_I$ and $y_I$ are your coefficients.

Stefan Perko
  • 12,467