4 ms·
This is the extended Euclidean algorithm, to find Bézout's coefficients. Column `d` contains the iterates of the classical Euclidean algorithm. Every row is th
by aaplok 4y ago
This is the extended Euclidean algorithm, to find Bézout's coefficients.
Column `d` contains the iterates of the classical Euclidean algorithm. Every row is the remainder of the two preceding rows. Eventually you get to the gcd.
Then, every number in `d` can be written as `ax+dy`. For the first two rows it's obvious: in the first row he sets `d=x`, so it easily comes that `a=1` and `b=0`. Similarly for the second row, where `d=y` then `a=0` and `b=1`.
Then from there it's basic algebra: if `a[i-2]x + b[i-2]y=d[i -2]` and `a[i-1]x + b[i-1]y=d[i -1]` you can easily prove that `a[i]x + b[i]y=d[i]`.