1

So I have been asked to find $d=(a,b)$ when $a=1109$ and $b=4999$ and express $d$ as a linear combination of $a$ and $b$

Well I have worked out that $d=1$ but I am struggling to express $d$ as a linear combination of $a$ and $b$

$4999=1109*4+563$
$1109=1*563+546$
$563=1*546+17$
$546=17*32+2$
$17=2*8+1$
$2=2*1$

then i have $d=1$ to work out $d$ as a linear combination i have $563=4999-4*1109$
$546=1109-1*563$
$546=1109-1(4999-1109*4)$
$546=5*1109-4999$
$17=563-546$
$17=4999-4*1109-1109-563$
$17=4999-4*1109-1109+4999-4*1109$
$17=2*4999-9*1109$
$2=546-17*32$
$2=...$
$2=-65*4999+293*1109$
$1=17-8*2$
$1=...$
$1=522*4999-2353*1109$

What I need to know is how do I work out $2=-65*4999+293*1109$ and $1=522*4999-2353*1109$ without pages of working out? also is what i have done trying to express $d$ as a linear combination of $a$ and $b$ correct? Is there a quicker way of working it out?

Many thanks for your help

  • Linear Diophantine equations are worked out algorithmically at a basic level, so expect long working out. – Display Name Oct 18 '13 at 05:15
  • for 1=5224999-23531109 i have a whole page of working out!! is this normal? – Bernard.Mathews Oct 18 '13 at 05:16
  • As Vladhagen has said below, you started at a strange position of the equation, other than that, yes it is expected for it to take a large amount of working, this purely being due to the algorithmic nature of it. Algorithmic methods are always much longer to solve than direct methods as you would expect, this can be likened to recursive sequences against direct sequences. – Display Name Oct 18 '13 at 05:21

6 Answers6

2

http://en.wikipedia.org/wiki/Continued_fraction#Finite_continued_fractions

The cross product of consecutive convergents in simple continued fractions are either $\pm 1.$ The first in the string is always $\frac{0}{1}.$ The second in the string is always the nonsensical $\frac{1}{0}.$ The convergents for $\frac{4999}{1109}$ are $$ \frac{0}{1}, \; \frac{1}{0}, \; \frac{4}{1}, \; \frac{5}{1}, \; \frac{9}{2}, \; \frac{293}{65}, \; \frac{2353}{522}, \; \frac{4999}{1109}.$$

We get little 2 by 2 determinant $$ 2353 \cdot 1109 - 522 \cdot 4999 = -1. $$

So $$ -2353 \cdot 1109 + 522 \cdot 4999 = 1. $$

This is not a difficult method to learn and has other uses. Note that the letters $a_i,$ called quotients on wikipedia, are $$ \langle 4; 1,1,32,8,2 \rangle. $$ These are $ \langle a_0; a_1,a_2,a_3,a_4,a_5 \rangle. $ I did it with a calculator. Beginning with the number $x_0 = \frac{4999}{1109} \approx 4.5077664563,$ we begin with $$ a_0 = \lfloor x_0 \rfloor = 4.$$ The fractional part is $x_0 - \lfloor x_0 \rfloor \approx 0.5077664563,$ and we take the reciprocal to get $$ x_1 = \frac{1}{x_0 - \lfloor x_0 \rfloor} \approx \frac{1}{0.5077664563} \approx 1.969804617 $$

Then $$ a_1 = \lfloor x_1 \rfloor = 1.$$ The fractional part is $x_1 - \lfloor x_1 \rfloor \approx 0.969804617,$ and we take the reciprocal to get $$ x_2 = \frac{1}{x_1 - \lfloor x_1 \rfloor} \approx \frac{1}{0.969804617} \approx 1.031135532. $$

Then $$ a_2 = \lfloor x_2 \rfloor = 1.$$ The fractional part is $x_2 - \lfloor x_2 \rfloor \approx 0.031135532,$ and we take the reciprocal to get $$ x_3 = \frac{1}{x_2 - \lfloor x_2 \rfloor} \approx \frac{1}{0.031135532} \approx 32.11764617. $$

Then $$ a_3 = \lfloor x_3 \rfloor = 32.$$ The fractional part is $x_3 - \lfloor x_3 \rfloor \approx 0.11764617,$ and we take the reciprocal to get $$ x_4 = \frac{1}{x_3 - \lfloor x_3 \rfloor} \approx \frac{1}{0.11764617} \approx 8.500064218. $$

Then $$ a_4 = \lfloor x_4 \rfloor = 8.$$ The fractional part is $x_4 - \lfloor x_4 \rfloor \approx 0.500064218,$ and we take the reciprocal to get $$ x_5 = \frac{1}{x_4 - \lfloor x_4 \rfloor} \approx \frac{1}{0.500064218} \approx 1.999743161. $$ it is here that experience becomes critically important. We are seeing the effect of tiny calculator roundoffs. The actual value is $x_5 = 2,$ from which we get $a_5 = 2,$ and that concludes the s.c.f.

Let us put in the "quotients" where they belong in the calculation: $$ \frac{0}{1}, \; \frac{1}{0}, \; \color{magenta}{\frac{4}{}}, \; \frac{4}{1}, \; \color{magenta}{\frac{1}{}}, \; \frac{5}{1}, \; \color{magenta}{\frac{1}{}}, \; \frac{9}{2}, \; \color{magenta}{\frac{32}{}}, \; \frac{293}{65}, \; \color{magenta}{\frac{8}{}}, \; \frac{2353}{522}, \; \color{magenta}{\frac{2}{}}, \;\frac{4999}{1109}.$$

In every case, given two consecutive numerators (in black) followed by a quotient (in magenta), the first numerator plus the second numerator times the quotient is the following numerator. So, $$ 0 + 1 \cdot 4 = 4, \; 1 + 4 \cdot 1 = 5, \; 4 + 5 \cdot 1 = 9, \; 5 + 9 \cdot 32 = 293, \; 9 + 293 \cdot 8 = 2353, \; 293 + 2353 \cdot 2 = 4999. $$

Same for denominators, $$ 1 + 0 \cdot 4 = 1, \; 0 + 1 \cdot 1 = 1, \; 1 + 1 \cdot 1 = 2, \; 1 + 2 \cdot 32 = 65, \; 2 + 65 \cdot 8 = 522, \; 65 + 522 \cdot 2 = 1109. $$

In case you are worried by this: the exact version, with fractions instead of calculator decimal approximations, is exactly what you have been doing: $$ x_0 = \frac{4999}{1109} = 4 + \frac{563}{1109}, $$ $$ x_1 = \frac{1109}{563} = 1 + \frac{546}{563}, $$ $$ x_2 = \frac{563}{546} = 1 + \frac{17}{546}, $$ $$ x_3 = \frac{546}{17} = 32 + \frac{2}{17}, $$ $$ x_4 = \frac{17}{2} = 8 + \frac{1}{2}, $$ $$ x_5 = \frac{2}{1} = 2. $$

Will Jagy
  • 139,541
1

$4999=4*1109+563$ so $563=4999-4*1109=b-4a$

$1109=1*563+546$ so $546=1109-563=a-(b-4a)=5a-b$

$563=1*546+17$ so $17=563-546=(b-4a)-(5a-b)=2b-9a$

$546=32*17+2$, so $2=546-32*17=(5a-b)-32(2b-9a)=293a-65b$

$17=8*2+1$ so $1=17-8*2=(2b-9a)-8(293a-65b)=522b-2353a=522*4999-2353*1109$

It's even faster and easier if you don't insist on using positive remainders all the time:

$4999=5*1109-546$ so $546=5*1109-4999=5a-b$

$1109=2*546+17$ so $17=1109-2*546=a-2(5a-b)=2b-9a$

$546=32*17+2$, so $2=546-32*17=(5a-b)-32(2b-9a)=293a-65b$

$17=8*2+1$ so $1=17-8*2=(2b-9a)-8(293a-65b)=522b-2353a=522*4999-2353*1109$

bof
  • 6,156
1

$\newcommand{\angles}[1]{\left\langle #1 \right\rangle}% \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}% \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}% \newcommand{\dd}{{\rm d}}% \newcommand{\ds}[1]{\displaystyle{#1}}% \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}% \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}% \newcommand{\ic}{{\rm i}}% \newcommand{\imp}{\Longrightarrow}% \newcommand{\pars}[1]{\left( #1 \right)}% \newcommand{\pp}{{\cal P}}% \newcommand{\sgn}{\,{\rm sgn}}% \newcommand{\ul}[1]{\underline{#1}}% \newcommand{\verts}[1]{\left\vert #1 \right\vert}$ \begin{align} 4999 &= 4\times 1109 + 563\tag{1} \\ 1109 &= 1\times 563 + 546\tag{2} \\ 563 &= 1\times 546 + 17\tag{3} \\ 546 & = 32 \times 17 + 2\tag{4} \\ 17 &= 8\times 2 + \color{#ff0000}{\large 1}\tag{5} \\ 2 &= 2\times 1 + 0\tag{6} \end{align}

With $\pars{4}$ and $\pars{5}$ we eliminate the factor $2$: $$ 8\times 546 - 17 = 256\times 17 - \color{#ff0000}{\large 1} \quad\imp\quad 8\times 546 = 257\times 17 - \color{#ff0000}{\large 1}\tag{7} $$

With $\pars{3}$ and $\pars{7}$ we eliminate the factor $17$: $$ 257\times 563 - 8\times 546 = 257\times 546 + \color{#ff0000}{\large 1} \quad\imp\quad 257\times 563 = 265\times 546 + \color{#ff0000}{\large 1}\tag{8} $$

With $\pars{2}$ and $\pars{8}$ we eliminate the factor $546$: $$ \!\!\!\!\!\!\!1109\times 265 - 257\times 563 = 265\times 563 - \color{#ff0000}{\large 1} \quad\imp\quad 1109\times 265 = 522\times 563 - \color{#ff0000}{\large 1}\tag{9} $$

With $\pars{1}$ and $\pars{9}$ we eliminate the factor $563$: $$ 4999\times 522 - 1109\times 265 = 2088\times 1109 + \color{#ff0000}{\large 1} \quad\imp\quad \color{#ff0000}{\large1 = 522\times \color{#0000ff}{4999} - 2353\times \color{#0000ff}{1109}} $$

Felix Marin
  • 89,464
1

Using the Euclid-Wallis Algorithm, $$ \begin{array}{r} &&4&1&1&32&8&2\\\hline 1&0&1&-1&2&-65&522&-1109\\ 0&1&-4&5&-9&293&-2353&4999\\ 4999&1109&563&546&17&2&1&0\\ \end{array} $$ The column with the $1$ at its base says that $(4999,1109)=1$ and that for any $k$, $$ (522-1109k)4999+(-2353+4999k)1109=1 $$ In particular, we have for $k=0$ $$ 522\cdot4999-2353\cdot1109=1 $$ or for $k=1$ $$ 2646\cdot1109-587\cdot4999=1 $$

robjohn
  • 345,667
0

Your general methodology seems correct. You have indeed worked backwards through your Euclidean Algorithm result and found coefficients for a and b. It is not entirely clear however why you began with 546 = 1109-1*563. You may want to begin with 4999-4*1109 = 563 and then perform a similar method as you have been. The work on these can be long unfortunately.

Vladhagen
  • 4,878
  • but 4999-4*1109 = 543 not 563?? – Bernard.Mathews Oct 18 '13 at 05:26
  • I would personally start with 2 = 546 - 32*17 – Display Name Oct 18 '13 at 05:32
  • thank you :) i will try that – Bernard.Mathews Oct 18 '13 at 05:35
  • Just did it and the absolute minimum number of steps is 12 for this question using the linear Diophantine method, and you have taken just that many, so take it that you are right :). (Not including the GCD(1109,4999)) – Display Name Oct 18 '13 at 05:38
  • The first line of your algorithm indicates that 4999-4*1109=563, which is correct. I always start from the top most line of my algorithm and work down, but as Display Name notes, you can start anywhere you want. The overall gist is, the work behind these linear combinations can be tedious. – Vladhagen Oct 18 '13 at 05:40
-1

Write down the quotients backwards 8 32 1 1 4, leaving out the last quotient 8. Then write 8 32 1 1 4 1 8 Then multiply the first 32 in the top row by the 8 in the bottom row and add the 1 in the second row, getting 257, and write 8 32 1 1 4 1 8 257 Then multiply the first 1 in the first row by the 257 in the second row and add the 8 in the second row, getting 265, and write 8 32 1 1 4 1 8 257 265
Multiply the second 1 in the first row by the 265 and add 257, getting 522, and write 8 32 1 1 4 1 8 257 265 522
Finally, multiply the 4 in the first row by 522 and add 265, getting 2353, and write 8 32 1 1 4 1 8 257 265 522 2353 Now write a - sign under the 8 in the second row, a + under the 257, etc, getting 8 32 1 1 4 1 8 257 265 522 2353 - + - + - Finally, write x under the 2353 and y under the 522, the result of which is x = -2253, y - 522, and we have solved 1109x + 4999y = 1.

Art DuPre'