Number of steps of euclidean algorithm

In summary, the Euclidean algorithm applied to $a$ and $b$ yields successive remainders $r_0, r_1, r_2, \dots$ where every two steps result in a remainder that is reduced by at least one half. This shows that the algorithm terminates in at most $2 \log_2{(b)}$ steps, which is equivalent to approximately seven times the number of digits in $b$. This can be proven by showing that $r_i > 2r_{i+2}$ for all $i$, and that $2\log_2b$ is approximately $6.6$ times the number of digits in $b$.
  • #1
evinda
Gold Member
MHB
3,836
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
  • #2
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.
 
  • #3
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}.
\]
 
  • #4
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)
 
  • #5
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?
 

What is the Euclidean algorithm?

The Euclidean algorithm is a mathematical method used to find the greatest common divisor (GCD) of two numbers. It involves repeatedly dividing the larger number by the smaller number until the remainder is equal to 0.

How many steps does the Euclidean algorithm take?

The number of steps in the Euclidean algorithm depends on the numbers being used. In the worst case scenario, the number of steps will be equal to the smaller of the two numbers being divided.

How do you know when the Euclidean algorithm is finished?

The Euclidean algorithm is finished when the remainder of the division is equal to 0. This means that the last number that was divided into the larger number is the GCD of the two numbers.

Can the Euclidean algorithm be used to find the GCD of more than two numbers?

Yes, the Euclidean algorithm can be extended to find the GCD of more than two numbers. This is done by finding the GCD of the first two numbers, then finding the GCD of that result and the next number, and so on until all numbers have been included.

Why is the Euclidean algorithm important?

The Euclidean algorithm is important because it is a simple and efficient method for finding the GCD of two numbers. It is also the basis for other important mathematical concepts, such as the extended Euclidean algorithm and the Chinese remainder theorem.

Similar threads

  • Introductory Physics Homework Help
Replies
15
Views
281
  • Calculus and Beyond Homework Help
Replies
5
Views
2K
Replies
2
Views
144
  • Advanced Physics Homework Help
Replies
11
Views
1K
  • Introductory Physics Homework Help
Replies
4
Views
580
  • Engineering and Comp Sci Homework Help
Replies
0
Views
524
  • Introductory Physics Homework Help
Replies
2
Views
1K
  • Special and General Relativity
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
Back
Top