Number of steps of euclidean algorithm

  • Context: MHB 
  • Thread starter Thread starter evinda
  • Start date Start date
  • Tags Tags
    Algorithm Euclidean
Click For Summary
SUMMARY

The Euclidean algorithm applied to two integers, \(a\) and \(b\), demonstrates that the remainder after every two steps is reduced by at least half, expressed mathematically as \(r_{i+2} < \frac{1}{2} r_i\). Consequently, the algorithm terminates in at most \(2 \log_2{(b)}\) steps, establishing that the number of steps is at most seven times the number of digits in \(b\). This conclusion is supported by the relationship \(2\log_2{b} \approx 6.6 \log_{10}{b}\), where \(\log_2{10}\) is a critical value in the analysis.

PREREQUISITES
  • Understanding of the Euclidean algorithm
  • Knowledge of logarithmic functions, specifically \(\log_2\) and \(\log_{10}\)
  • Familiarity with mathematical inequalities
  • Basic algebraic manipulation skills
NEXT STEPS
  • Study the properties of logarithms, particularly the change of base formula
  • Explore the efficiency of the Euclidean algorithm in various applications
  • Investigate the relationship between the number of digits in a number and its logarithmic representation
  • Learn about the implications of algorithmic complexity in computational mathematics
USEFUL FOR

Mathematicians, computer scientists, and students studying algorithms or number theory will benefit from this discussion, particularly those interested in the efficiency of the Euclidean algorithm and its applications in computational contexts.

evinda
Gold Member
MHB
Messages
3,741
Reaction score
0
Hello! (Wave)

I am looking at the following exercise: Let $b=r_0, r_1, r_2, \dots$ be the successive remainders in the Euclidean algorithm applied to $a$ and $b$. Show that after every two steps, the remainder is reduced by at least one half. In other words, verify that $$r_{i+2}< \frac{1}{2} r_i \ ,\text{ for every } i=0,1,2, \dots$$Conclude that the Euclidean algorithm terminates in at most $2 \log_2{(b)}$ steps, where $\log_{2}$ is the logarithm to the base $2$. In particular, show that the number of steps is at most seven times the number of digits in $b$. [ Hint: What is the value of $\log_2{10}$ ?]

I have tried the following:

The general formula for $r_{i-1}$ in the Euclidean algorithm is the following:

$$r_{i-1}=q_{i+1} r_i+r_{i+1}$$So we have: $r_i=q_{i+2} r_{i+1}+r_{i+2} \\=q_{i+2}(q_{i+3} r_{i+2}+r_{i+3})+r_{i+2} \\=q_{i+2} q_{i+3} r_{i+2} +q_{i+2} r_{i+3}+r_{i+2}\\ \geq r_{i+2}+q_{i+2} r_{i+3}+r_{i+2} \\=2r_{i+2}+q_{i+2} r_{i+3}> 2r_{i+2}$

So it follows that $r_{i+2}<\frac{1}{2} r_i$.

As for the number of steps, I have thought the following:We have that $b=r_0>2r_2> 4r_4>8r_6> \dots> 2^m r_{2m}$

The Euclidean algorithm terminates when we find a remainder that is equal to zero.

So we check when $r_{2m}<1$.

$r_{2m}<1 \Rightarrow 2^m r_{2m}<2^m$.

We also have that $2^m r_{2m}<b$.

But from these two inequalities, we cannot find a relation between $m$ and $b$, can we?
 
Mathematics news on Phys.org
evinda said:
We also have that $2^m r_{2m}<b$.
Take logs to base 2 in that inequality: $m + \log_2 r_{2m} < \log_2b$.

If $m > \log_2b$ then $\log_2 r_{2m} < \log_2b - m < 0$. So $r_{2m}<1$, which means that $r_{2m} =0$, and the algorithm has terminated.

Since $m > \log_2b\ \Longrightarrow\ 2m > 2\log_2b$, this shows that as soon as the algorithm reaches the $2m$th step, with $2m > 2\log_2b$, the algorithm will terminate.
 
The fact that $r_i>2r_{i+2}$ can be shown slightly more easily. We have $r_i>r_{i+1}$ for all $i$ because $r_{i+1}$ is the remainder when something (namely, $r_{i-1}$) is divided by $r_i$. So we have
\[
r_i=q_{i+2}r_{i+1}+r_{i+2}\ge r_{i+1}+r_{i+2}>2r_{i+2}.
\]
 
Evgeny.Makarov said:
The fact that $r_i>2r_{i+2}$ can be shown slightly more easily. We have $r_i>r_{i+1}$ for all $i$ because $r_{i+1}$ is the remainder when something (namely, $r_{i-1}$) is divided by $r_i$. So we have
\[
r_i=q_{i+2}r_{i+1}+r_{i+2}\ge r_{i+1}+r_{i+2}>2r_{i+2}.
\]

Yes, I see... (Smile)
 
Opalg said:
Take logs to base 2 in that inequality: $m + \log_2 r_{2m} < \log_2b$.

If $m > \log_2b$ then $\log_2 r_{2m} < \log_2b - m < 0$. So $r_{2m}<1$, which means that $r_{2m} =0$, and the algorithm has terminated.

Since $m > \log_2b\ \Longrightarrow\ 2m > 2\log_2b$, this shows that as soon as the algorithm reaches the $2m$th step, with $2m > 2\log_2b$, the algorithm will terminate.

I understand... So the algorithm terminates in at least $2\log_2b$ steps, or not? (Thinking)

In order to show that the number of steps is at least seven times the number of digits in $b$, we use the fact that$$2\log_2b=2\log_2{10} \cdot \log_{10}{b} \approx 6.6 \log_{10}{b}$$

Right?
 

Similar threads

Replies
15
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K