12

Find one integer solution to the Diophantine equation \begin{equation*} 18x+14y+63z=5. \end{equation*}

If this were only a linear equation over $\mathbb{Z}^2$, then I could easily solve it by using the extended Euclidean algorithm... but I have no idea how to do this with more than 2 unknowns...

Mirrana
  • 9,009

3 Answers3

15

You solve $18 u + 14 v = 2 = \gcd(18,14).$ Solve $2 w + 63 z = 1.$ Combine to get $18 x + 14 y + 63 z = 1.$ Then multiply all by $5.$

Will Jagy
  • 139,541
  • 1
    Could you elaborate on the "combine" part? I get a solution to $18u+14v=2$ with $u=-3$, $v=4$. Then if I solve $2w+63z=1$, I get $w=-31$ and $z=1$. What do I combine where to get $18u+14v+63z=1$? I tried plugging in $u,v,z$ as I found them and I get $(-3)(18)+(4)(14)+63=65... – Mirrana Oct 04 '13 at 01:56
  • 3
    @agent154 $$(18u+14v)w + 63z = 1$$ – Will Jagy Oct 04 '13 at 01:58
  • 1
    you have $18(-3)+14(4)=2$ and $2(-31)+63(1)=1$...from $18(-3)+14(4)=2$ you have $18(-3.(-31))+14(4.(-31))=2(-31)$.. now combine with $2(-31)+63(1)=1$.. –  Oct 04 '13 at 01:58
  • 1
    OK, I did the math and it works out. Very complicated work to get used to... I suppose I just need to do it a few times to get familiar with the procedure. – Mirrana Oct 04 '13 at 02:02
  • 1
    @agent154, do $10x + 12 y + 15 z = 163.$ – Will Jagy Oct 04 '13 at 02:15
  • may be you should try with another example to get used to the process... may be with $63x+70y+15z=2010$ –  Oct 04 '13 at 02:15
4

Hint $\ \color{#c00}{18\!-\!14}\,\mid\, 63\!+\!1 $ $\, \Rightarrow\,\overbrace{16\,(18\!-\! 14)-63 = 1}^{\textstyle 18x + 14y + 63z = 1}.\,$ Scale that by $\,5\,$ to get $\,d=5\,$ on RHS.

Remark $\ $ The idea is simply to search for a "small" linear combination $\,n = \color{#c00}{ia+jb}\,$ of two elements $\,a,b\,$ of $\,\{14,18,63\}\,$ such that the 3rd element satisfies $\ c\equiv \pm1 \pmod n,\,$ hence $\, \pm1 = c+kn = c + ki\,a + kj\,b\,$ thus scaling by $\pm d\,$ yields $d$ as a linear combination of $a,b,c.\,$ Above the first "small" number we see is $\, n = \color{#c00}{18\!-\!14} = 4\,$ works since $63\equiv -1\pmod {\!4}.\,$ Notice that we could replace $\, k = \pm1\,$ by any divisor of $\,d,\,$ then scale by $\,d/k\,$ to get $\,d\,$ on RHS.

The reason for choosing $n$ "small" is that this increases the probability that $\,c\equiv \pm1\pmod{\! n},\,$ e.g. $100\%$ chance if $n = 2,\,$ $67\%$ if $n = 3.\,$ We know (by Bezout) that the smallest such $n$ is $\,\gcd(a,b)\,$ but - as we saw above - often simpler choices work such as $\,b-a.$

Below we will see that the above optimization works when the extended Euclidean algorithm terminates in a couple steps.

Algorithmically, using the Extended Euclidean Algorithm to compute $\rm\,gcd(63,18,14) = 1\,$

$$\begin{array}{rrr} [1]&\ 63& 1& 0& 0\\ [2]&\ 18& 0& 1& 0\\ [3]&\ 14& 0& 0& 1\\ [2] -[3]\, =\, [4]& 4& \!\!0& 1& -1\\ 16[4] -[1]\, =\,[5]& 1& -1& 16& \!\!\!\!-16 \end{array}\qquad\qquad\qquad\quad$$

where the row $\ n\,\ a\,\ b\,\ c\,\ d\ $ denotes that $\ n = 63a + 18 b + 14 c.\ $ Thus the final row yields

$$\quad 1 = -63 +16(18) - 16(14)$$

See here for another worked example, and see here for an explicit formula for the general trivariate linear Diophantine equation (in terms of solutions of associated bivariate equations).

Bill Dubuque
  • 272,048
2

[For the following paragraphs, please refer to the figure at the end of the last paragraph (the figure is also available in PDF).]

The manipulations performed from steps (0) to (17) were designed to create the linear system of equations (0a), (5a), (11a) and (17a). The manipulations end when the absolute value of a coefficient of the latest equation added is 1 (see (17)).

Equation (0a) is given. It is possible to infer equations (5a), (11a) and (17a) from (0), (5) and (11) respectively without performing manipulations (0) to (17) directly. In every case, select the smallest absolute value coefficient, generate the next equation by replacing every coefficient with the remainder of the coefficient divided by the selected coefficient (smallest absolute value coefficient) – do the same with the right-hand constant – and add the new variable whose coefficient is the smallest absolute value coefficient. If the new equation has a greatest common divisor greater than one, divide the equation by the greatest common divisor (it may be necessary to divide this greatest common divisor from previous equations). Stop when the absolute value of a coefficient of the latest equation added is 1. Then proceed to solve the linear systems of equations.

enter image description here

  • 1
    The extended euclidean algorithm can be presented much more simply - see my answer and its link. – Bill Dubuque Jun 27 '17 at 15:49
  • 2
    I found several errors in my answer. However instead of replacing the answer with a correction version, I am including a link to the correction: https://www.researchgate.net/publication/318339228_How_I_Solved_18x_14y_5_mod_63_A_Correction_to_my_Reply_for_How_do_I_solve_a_linear_diophantine_equation_with_three_unknowns_at_Mathematics_Stack_Exchange. – John Frederick Chionglo Jul 23 '17 at 09:13