Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Extended Euclidean algorithm
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Proof === As <math> 0\le r_{i+1}<|r_i|, </math> the sequence of the <math> r_i </math> is a decreasing sequence of nonnegative integers (from ''i'' = 2 on). Thus it must stop with some <math> r_{k+1}=0.</math> This proves that the algorithm stops eventually. As <math> r_{i+1}= r_{i-1} - r_i q_i,</math> the greatest common divisor is the same for <math>(r_{i-1}, r_i)</math> and <math>(r_{i}, r_{i+1}).</math> This shows that the greatest common divisor of the input <math>a=r_0, b=r_1 </math> is the same as that of <math> r_k, r_{k+1}=0.</math> This proves that <math> r_k </math> is the greatest common divisor of ''a'' and ''b''. (Until this point, the proof is the same as that of the classical Euclidean algorithm.) As <math> a=r_0</math> and <math> b=r_1,</math> we have <math>as_i+bt_i=r_i</math> for ''i'' = 0 and 1. The relation follows by induction for all <math>i>1</math>: <math display="block">r_{i+1} = r_{i-1} - r_i q_i = (as_{i-1}+bt_{i-1}) - (as_i+bt_i)q_i = (as_{i-1}-as_iq_i) + (bt_{i-1}-bt_iq_i) = as_{i+1}+bt_{i+1}.</math> Thus <math>s_k</math> and <math>t_k</math> are Bézout coefficients. Consider the matrix <math display="block">A_i=\begin{pmatrix} s_{i-1} & s_i\\ t_{i-1} & t_i \end{pmatrix}.</math> The recurrence relation may be rewritten in matrix form <math display="block">A_{i+1} = A_i \cdot \begin{pmatrix} 0 & 1\\ 1 & -q_i \end{pmatrix}.</math> The matrix <math>A_1</math> is the identity matrix and its determinant is one. The determinant of the rightmost matrix in the preceding formula is −1. It follows that the determinant of <math>A_i</math> is <math>(-1)^{i-1}.</math> In particular, for <math>i=k+1,</math> we have <math>s_k t_{k+1} - t_k s_{k+1} = (-1)^k.</math> Viewing this as a Bézout's identity, this shows that <math>s_{k+1}</math> and <math>t_{k+1}</math> are [[coprime]]. The relation <math>as_{k+1}+bt_{k+1}=0</math> that has been proved above and [[Euclid's lemma]] show that <math>s_{k+1}</math> divides {{mvar|b}}, that is that <math>b=ds_{k+1}</math> for some integer {{mvar|d}}. Dividing by <math>s_{k+1}</math> the relation <math>as_{k+1}+bt_{k+1}=0</math> gives <math>a=-dt_{k+1}.</math> So, <math>s_{k+1}</math> and <math>-t_{k+1}</math> are coprime integers that are the quotients of {{mvar|a}} and {{mvar|b}} by a common factor, which is thus their greatest common divisor or its [[additive inverse|opposite]]. To prove the last assertion, assume that ''a'' and ''b'' are both positive and <math>\gcd(a,b)\neq\min(a,b)</math>. Then, <math>a \neq b </math>, and if <math>a < b</math>, it can be seen that the ''s'' and ''t'' sequences for (''a'',''b'') under the EEA are, up to initial 0s and 1s, the ''t'' and ''s'' sequences for (''b'',''a''). The definitions then show that the (''a'',''b'') case reduces to the (''b'',''a'') case. So assume that <math>a > b</math> [[without loss of generality]]. It can be seen that <math>s_2</math> is 1 and <math>s_3</math> (which exists by <math>\gcd(a,b)\neq\min(a,b)</math>) is a negative integer. Thereafter, the <math>s_i</math> alternate in sign and strictly increase in magnitude, which follows inductively from the definitions and the fact that <math>q_i\geq 1</math> for <math>1 \leq i \leq k</math>, the case <math>i = 1</math> holds because <math>a > b</math>. The same is true for the <math>t_i</math> after the first few terms, for the same reason. Furthermore, it is easy to see that <math>q_k \geq 2</math> (when ''a'' and ''b'' are both positive and <math>\gcd(a,b)\neq\min(a,b)</math>). Thus, noticing that <math>|s_{k+1}| = |s_{k-1}| + q_k |s_k|</math>, we obtain <math display="block">|s_{k+1}|=\left |\frac{b}{\gcd(a,b)} \right | \geq 2|s_k| \qquad \text{and} \qquad |t_{k+1}|= \left |\frac{a}{\gcd(a,b)} \right | \geq 2|t_k|.</math> This, accompanied by the fact that <math>s_k,t_k</math> are larger than or equal to in absolute value than any previous <math>s_i</math> or <math>t_i</math> respectively completed the proof.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)