2

Starting with an ordered quadruple of positive integers, a generalized Euclidean algorithm is applied successively as follows: if the numbers are $x, y, u, v$ and $x > y,$ then the quadruple is replaced by $x − y, y, u + v, v.$ Otherwise, it is replaced by $x, y − x, u, v + u.$

The algorithm stops when the numbers in the first pair become equal (in which case they are equal to the greatest common divisor of x and y). Assume that we start with $m, n, m, n.$ Prove that when the algorithm ends, the arithmetic mean of the numbers in the second pair equals the least common multiple of $m$ and $n.$

The quantity $I = xv+yu$ does not change under the operation, so it remains equal to $2mn$ throughout the algorithm. When the first two numbers are both equal to $\gcd(m, n),$ the sum of the latter two is $ \frac{2mn}{\gcd(m,n)} = 2\operatorname{lcm}(m, n)$.

(St. Petersburg City Mathematical Olympiad, 1996)

Can you please explain why the sum of the latter two is $ \frac{2mn}{\gcd(m,n)} = 2\operatorname{lcm}(m, n)$. Also, a link to similar problems is also welcome.

Thomas Andrews
  • 177,126
  • Wow, that's a slick invariance. – Calvin Lin May 27 '21 at 15:03
  • Of course @CalvinLin. Therefore, I could not understand it. – punemath May 27 '21 at 15:08
  • I was only referring to coming up with the invariance $ I = xv + yu$. While I see why that's what we want, I'm not certain I would have come up with it during a competition. The rest seems standard / well-known to me (but of course, not necessarily to you). $\quad$ However, seeing your reply to Ross, it seems like you don't understand what an invariance is? – Calvin Lin May 27 '21 at 15:10
  • I got the first part. Just confused because we got down the first pair = gcd(m,n) How did the second pair become = $\frac{2mn}{gcd(m,n)}$ And seriously, it is a really nice question. – punemath May 27 '21 at 15:19
  • @CalvinLin Just forgot to see that the question was asking about the arithmetic mean. Thanks anyway. – punemath May 27 '21 at 16:24
  • @CalvinLin The invariance is simply invariance of a determinant under a column operation - see my answer. So it's natural (vs. slick) from that viewpoint. – Bill Dubuque May 28 '21 at 13:55
  • @BillDubuque Could you check this https://math.stackexchange.com/questions/4152739/question-based-on-vectors – punemath May 28 '21 at 13:58

2 Answers2

3

It helps to understand the idea behind the algorithm. It uses the subtractive Euclidean algorithm to change basis, iteratively transforming $\,m\Bbb Z + n\Bbb Z\,$ into $\,d\Bbb Z + d\Bbb Z = d\Bbb Z,\,$ where $\,d = \gcd(m,n),\,$ while simultaneously keeping track of the coordinates of some given number $\,k = v_0 m + u_0 n\,$ in each transformed basis. The (loop) invariant is that the bases are equivalent (same span), i.e. $\,x_j \Bbb Z + y_j\Bbb Z = m\Bbb Z + n\Bbb Z$. and that $\,v_j x_j + u_j y_j = k = v_0 x_0 + u_0 y_0,\,$ i.e. $\,(v_j,u_j)\,$ are the coordinates of $\,k\,$ in the current basis $\,(x_j,y_j).\,$ Span persistence follows because the subtractive Euclidean algorithm changes bases via elementary transformations (i.e. determinant $=\pm1),\,$ which are invertible. The coordinate persistence follows by simple algebra, naturally viewed as persistence of the determinant under column operations, i.e. if we represent $(x,y,u,v)$ by $\begin{bmatrix} x & y\\ -u & v \end{bmatrix}$ then the Euclidean reduction step subtracts the column with least first row entry from the other column, which preserves the determinant, e.g. if $\,x < y\,$ then the reduction step simply subtracts the $\rm\color{#c00}{second}$ column from the first, as displayed below

$$\begin{align} (x,y,u,v)\ &\to\ (x\!-\!y,y, u\!+\!v,v)\,\ \ \text{has matrix form below:}\\[.5em] \begin{bmatrix} \ \ x & \color{#c00}y\\ -u & \color{#c00}v \end{bmatrix} \ &\to \ \begin{bmatrix} \,\ \ x-\color{#c00}y & y\\ -(u+\color{#c00}v) & v \end{bmatrix} = \begin{bmatrix} \ \ x & y\\ -u & v \end{bmatrix} \begin{bmatrix} \ \ 1 & 0\\ -1 & 1 \end{bmatrix} \end{align}\qquad$$

Since the reduction step amounts to multiplying by a matrix with determinant $=1$ it preserves the determinant (our loop invariant $I)$. Thus the algorithm may be viewed as column subtractions on these matrices, which amounts to augmenting the subtractive Euclidean algorithm (on rows $[x,y])$ to $\,2\times 2\,$ matrices, by appending a 2nd row $[-u,v]$ for the coordinates of the given number.

Finally, to answer your question about the invariant at termination. note that in the OP we have $\,v_0,u_0 = n,m\,$ so $\, k = 2mn,\,$ so when the algorithm terminates with $\,x = y = d\,$ we have

$$\begin{align} \overbrace{\color{#c00}d(v\!+\!u)}^{\textstyle \color{#c00}xv+\color{#c00}yu} &=\, 2mn\\[.4em] \iff \frac{v+u}2 &= \frac{mn}d = {\rm lcm}(m,n)\end{align}\qquad$$

where we used $\,d\,{\rm lcm}(m,n) = \gcd(m,n)\,{\rm lcm}(m,n) = mn\,$ by here.

Remark $ $ To learn more about the linear algebra at the heart of the matter see the Hermite - Smith normal form and closely related topics.

Bill Dubuque
  • 272,048
2

It is a theorem that $\operatorname{LCM}(m,n)\operatorname{GCD}(m,n)=mn$. To see this, consider the powers of a prime dividing $m,n$ The maximum is a factor of the $\operatorname{GCD}$, the minimum is a factor of the $\operatorname{LCM}$ so the powers on each side are equal.

To see the invariance, apply the rule. We assume $x \gt y$ and use primes for the new variable values $$x'v'+y'u'=(x-y)v+y(u+v)=xv+yu$$ The other case is similar

Ross Millikan
  • 374,822
  • Or you can prove it using Bezout’s identity. You can easily show that $\frac{mn}{\gcd(m,n)}$ is a common multiple, and then show that $M\gcd(m,n)$ is divisible by $mn$ using Bezout whenever $M$ is a common multiple. – Thomas Andrews May 27 '21 at 15:01
  • My question was about the second pair. It is given that the Euclidean Algorithm needs to be applied till the first pair = gcd(m,n). How does it imply that the last two pairs equal $\frac{2mn}{gcd(m,n)}$ – punemath May 27 '21 at 15:05
  • Thanks for the clarification Ross. Got it! – punemath May 27 '21 at 16:23
  • @punemath The invariance formula has a natrual interpretation as persistence of a determinant under a column operation (subtraction), as I explain in my answer. – Bill Dubuque May 28 '21 at 13:52