MakarovSuites
English
EnglishDeutschРусскийУкраїнськаFrançaisEspañolItalianoPolski
Contact & licences

Math

Euclid's algorithm and continued fractions

A brass-and-wood division bench shows why gcd(a,b)=gcd(b,r). Follow the remainder, inspect exact Bézout coefficients and continued fractions, compare pairs and explore a reproducible sample.

Euclid's algorithm and continued fractions — Actual application image
Actual application image

What happens

A brass-and-wood division bench shows why gcd(a,b)=gcd(b,r). Follow the remainder, inspect exact Bézout coefficients and continued fractions, compare pairs and explore a reproducible sample.
Lengths illustrate exact integer division. The measured channels share one scale; the remainder inset has its own labelled scale. A zero remainder ends the algorithm.
Fibonacci pairs give small inputs for long runs. Lamé is a coarse upper bound.
Error is measured against the input rational number, not π.

Equations used in the module
Equations
a = q*b + r, 0 <= r < b; next pair (b,r); gcd(a,b)=gcd(b,r).
Count the final division with zero remainder. A zero input needs no divisions; convention gcd(0,0)=0.
The scene orders magnitudes: high=max(|A|,|B|), low=min(|A|,|B|).
Bézout: gcd(A,B)=x*A+y*B. Every displayed remainder also has exact coefficients of the original A,B.
For low>0, Euclidean quotients are the finite continued fraction of high/low.
355/113=[3;7,16]; 1071/462=[2;3,7]=51/22. The final convergent equals the input rational exactly.
For a convergent p/q of that rational: error=|high*q-low*p|/(low*q) < 1/q^2.
This error is against high/low, not pi. There is no pi accuracy claim here.
Lamé: divisions <= 5*(decimal digits of the positive smaller input).
F20=6765, F19=4181 take 18 divisions; the coarse Lamé bound is 20, not attained.
Consecutive Fibonacci numbers give minimal ordered positive inputs for a prescribed count (a>b>0).
They are not the only pairs with that count: multiplying both inputs by the same positive integer preserves quotients.
For this sorted uniform-pair experiment: empirical reference (12 ln 2 / pi^2)*ln N - 0.444.
12 ln 2 / pi^2 = 0.84276591327219452; -0.444 is fitted, not a universal constant or finite-N theorem.
Sample both integers independently from 1..N, sort for division, retain ties, count the terminal zero.
Standard error = sample standard deviation / sqrt(trials); a finite sample does not prove an asymptotic law.

Related experiments

Back to catalogue
The modular clock — Actual application image

Math

The modular clock

A dial of m marks and one hand. Adding a step draws a star that closes after m/gcd(s, m) moves; multiplying draws a cycle whose length divides phi(m). Some moduli have no primitive root at all, and the card says so - that is a theorem, not a failed search.

The sieve and the density of primes — Actual application image

Math

The sieve and the density of primes

Work the sieve by hand on numbered tiles: take the next divisor, predict where its wave starts, and watch it strike its multiples - the ones already struck are only touched. Beside it, pi(x) counted against the approximations x/ln x and Li(x).

RSA on small numbers — Actual application image

Math

RSA on small numbers

One message travels through two modular powers on a wood-and-brass desk. Execute the actual integer steps, inspect small permutations or large sampled maps, and find a divisor with a counted search.