Jump to content

Talk:Euclidean algorithm

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Featured articleEuclidean algorithm is a featured article; it (or a previous version of it) has been identified as one of the best articles produced by the Wikipedia community. Even so, if you can update or improve it, please do so.
Main Page trophyThis article appeared on Wikipedia's Main Page as Today's featured article on June 18, 2009.
Article milestones
DateProcessResult
April 24, 2009Peer reviewReviewed
May 19, 2009Featured article candidatePromoted
February 7, 2015Featured article reviewKept
Current status: Featured article

Integers: ordinary, normal, usual, real, Gaussian

[edit]

In the § Gaussian integers section, we find these expressions:

  • "ordinary integers"
  • "normal integers".

I found these terms confusing, since

  1. I don't recall seeing them used, in decades of reading maths, before this; and
  2. The phrase "normal integers" occurs in close proximity to a discussion of a norm.

Perhaps both of the above phrases were meant to specify the usual or everyday integers, namely those in (or isomorphic to those in) the real numbers? In any case, the sense of the section wouldn't suffer, and accuracy would improve, if we were to replace both "ordinary integers" and "normal integers" by "real integers".

Before I make such a change, I'd like to hear other opinions.

yoyo (talk) 11:55, 6 November 2018 (UTC)[reply]

The phrase "ordinary integer" is commonly used for distinguishing usual integers from Gaussian integers, and more generally from algebraic integers. The phrase "normal integer" is less common and must changed into "ordinary integer". "Real integer" is not a good idea, because it would be WP:OR, and also because (for example) is an algebraic integer and a real number. I'll change "normal" to "ordinary", and add an explanatory footnote after the first use of "ordinary". D.Lazard (talk) 12:35, 6 November 2018 (UTC)[reply]
I agree with D.Lazard. "Ordinary integers" is not at all confusing, "normal integers" may be slightly confusing, but "real integers" is definitely confusing. Maproom (talk) 14:28, 6 November 2018 (UTC)[reply]

Inconsistent history

[edit]

The present text of the article says that the Euclidean algorithm was first described in Europe by Bachet in 1624. This can hardly be true if it was already described in Euclid's Elements, which was known in Europe in various editions and translations long before Bachet.109.149.2.98 (talk) 13:49, 7 April 2019 (UTC)[reply]

Point well taken. The source only says that Bachet gave the first numerical description of the algorithm in Europe. I'll edit this. --Bill Cherowitzo (talk) 19:02, 7 April 2019 (UTC)[reply]

Section "Non commutative rings"

[edit]

It seems that the only known example is the ring of Hurwitz quaternions. This must be clarified. If is true, the section must be renamed "Hurwitz quaternions". Otherwise, it must be named "Non commutative Euclidean rings" and moved to Euclidean domain. D.Lazard (talk) 08:47, 18 June 2019 (UTC)[reply]

Inaccurate implementations

[edit]

I feel the implementations given in the Implementations sections are all inaccurate. For example, gcd(-6, 0) is 6, but the implementations return -6. This is wrong because GCDs are always non-negative. Hexagonalpedia (talk) 12:18, 23 May 2021 (UTC)[reply]

 Fixed D.Lazard (talk) 16:39, 24 May 2021 (UTC)[reply]

Flowcharts

[edit]

At least one flowchart that represents an Euclidean algorithm could be expected.  Now no flowchart in the current article.  So here are flowcharts.

As though there is no instruction modulo in computing,  neither in Python nor in JavaScript for example,  the first algorithm computes a remainder through successive subtractions.  The second algorithm uses successive modulo operations — % in Python or in JavaScript —,  in order to yield the GCD of two natural numbers.  A little more complicated,  the third algorith is conceived for the easiest mathematical proof of the existence of this “great” divisor,  which is multiple of every common divisor of a given pair of natural numbers.  This last algorithm keeps unchanged the common divisors of such a pair at every step,  by replacing the greatest integer with the positive difference between the two.

By  iterating  the  subtraction  of  number   d,
calculation  of   modulo    for  and  d
members  of  ℕ,    when  is  not  zero.   Example:
if   n = 85  and  d = 20,  
then  variable   r   passes
through  the  values:     85 ↠ 65 ↠ 45 ↠ 25 ↠ 5,
along   four   courses   of   the   loop.    Therefore,
according  to  the  algorithm,   divide   85  by  20
yields   the   remainder
85 – 4 × 20  =  85 modulo 20  =  5.
Through  the  successive  divisions  of  the
Euclidean  algorithm,   calculation  of  the  GCD
of   natural   numbers    and  g.   For  example,
if  their  starting  values  are   20  and  85,   then
dividend,   divisor  and  remainder  of  the  unique
division   of   the   loop   are,    at  every  step,
three  successive  terms  of  this  sequence:
20,  85,  20,  5,  0
  (5  being  a  divisor  of  20).

Result:    gcd(20, 85)  =  5.

Every  pair  of  such  a  sequence:
{85,  20},   {65,  20},   {45,  20}
,
and  so  on,   has  the  same  set  of
common   divisors   at   every   step.
So  the  “great”  divisor,   multiple  of
every  divisor  of   85  and  20   in  this
example,   can  be  computed  simply
through  successive  subtractions.
About  the  greatest  common  divisor  of  two  natural  numbers,   three  flowcharts.
If  either  given  integer  is  zero,   then  their  greatest  common  divisor
is  the  other  number,   because  zero  is  the  only  multiple
of  every  integer,   the  “greatest”  for  the  divisibility.

These three algorithms could be inserted in introduction just after the text,  while the antique diagram,
less comprehensible than a flowchart,  could be transfered in section
“Background: greatest common divisor” on the right,
the   rectangle   being   placed   on   the   left.
All  captions  of  this  multiple  image  are
well  presented  in  the  first  two  available  font‑sizes.
  Arthur Baelde (talk) 14:28, 5 September 2024 (UTC)[reply]

Flowcharts were a popular method for describing algorithms whent the main control instruction of programming languages was the "go to". Presently, flowcharts are generally replaced by pseudo-code, which is more concise, easier to understand because of its linear structure, and more powerful (it describes programs that cannot be described with flowcharts). The article Flowchart contains The flowchart became a popular tool for describing computer algorithms, but its popularity decreased in the 1970s, when interactive computer terminals and third-generation programming languages became common tools for computer programming, since algorithms can be expressed more concisely as source code in such languages. Often pseudo-code is used, which uses the common idioms of such languages without strictly adhering to the details of a particular one. Also, flowcharts are not well-suited for new programming techniques such as recursive programming.
Also, the manual of style of Wikipedia MOS:MATH#Algorithms says An article about an algorithm may include pseudocode or in some cases source code in some programming language., and does not mention flowcharts at all. Effectively, there are many Wikipedia articles that contain pseudocode, and very few that contain flowcharts.
Presently, the section § Implementations contains the pseudo-code of three versions of the Euclidean algorithm. The most complicate one consists of 7 short lines, and the third one can definitively not be converted into a flow chart. Also, the second one is a much better implementation than your thirs flowcharts.
So, there is no reason for introducing flowcharts in this article, and, in any case, their place is not in the lead. D.Lazard (talk) 16:26, 5 September 2024 (UTC)[reply]
I think it would be okay in principle to have a flowchart somewhere in this article, though an algorithm this simple can also be described as a paragraph or written as pseudocode.
I find these particular flow charts pretty hard to read and visually distracting. The most important feature of flow charts is organizing information spatially so it can be easily visually scanned. –jacobolus (t) 17:16, 5 September 2024 (UTC)[reply]

Interactive worked examples

[edit]

Compute the Euclidean algorithm step by step:
a = 119; b = 61 a = 119; b = 61

= q0 × + r0
q0 =  ; r0 =
Since r0=0 the algorithm is finished. Thus GCD( , ) = .


= q1 × + r1

q1 =  ; r1 =
Since r1=0 the algorithm is finished. Thus GCD( , ) = .


= q2 × + r2

q2 =  ; r2 =
Since r2=0 the algorithm is finished. Thus GCD( , ) = .


= q3 × + r3

q3 =  ; r3 =
Since r3=0 the algorithm is finished. Thus GCD( , ) = .


= q4 × + r4

q4 =  ; r4 =
Since r4=0 the algorithm is finished. Thus GCD( , ) = .


= q5 × + r5

q5 =  ; r5 =
Since r5=0 the algorithm is finished. Thus GCD( , ) = .


= q6 × + r6

q6 =  ; r6 =
Since r6=0 the algorithm is finished. Thus GCD( , ) = .


= q7 × + r7

q7 =  ; r7 =
Since r7=0 the algorithm is finished. Thus GCD( , ) = .


= q8 × + r8

q8 =  ; r8 =
Since r8=0 the algorithm is finished. Thus GCD( , ) = .


= q9 × + r9

q9 =  ; r9 =
Since r9=0 the algorithm is finished. Thus GCD( , ) = .


= q10 × + r10

q10 =  ; r10 =
Since r10=0 the algorithm is finished. Thus GCD( , ) = .

Number is too big for the calculator Start

Restart Next →

I've noticed that a lot of Wikipedia articles on algorithms have worked examples or sometimes GIF animations showing the algorithm step by step. I was thinking it would be cool if there could be an interactive worked example, where the reader can chose the inputs and then see the algorithm work step-by-step. I decided to have a go at trying to create something like that - see my demo on the right. I was wondering what people think of the idea? Bawolff (talk) 16:42, 14 November 2024 (UTC)[reply]