-2

A man paid $11.37$ for $39$ cent and $69$ cent pens. We wish to solve for

$$39x+69y=1137$$

However, since $(39,69)=3 \mid 1137$ this reduces down to

$$13x+23y=379 \space \space \space (*)$$

Then the text reads: Using the Euclidean algorithm on $13$ and $23$ and solving the equations backwards gives

$$13(-7)+23(4)=1$$

I wanna know how they got $-7$ and $4$ so quickly and why this implies $-7,4$ are solutions to $(*)$. Thanks in advance.

homosapien
  • 4,157
  • It’s a guess. Pure Hit and Trial. As for the second question, they are not solutions; 13(-7)+23(4)=1 implies 13(-7379)+23(4379)=379, so x=-7379 and y=4379 are solutions to (*). – insipidintegrator Jun 11 '22 at 18:12
  • 1
    No, it is not a guess. It is the Euclidean algorithm, which is very quick. It gives $13\cdot(-7)+23\cdot 4=1$. Now multiply the equation by $379$. See this post, for example. – Dietrich Burde Jun 11 '22 at 18:13
  • 1
    Did the text say “quickly?” It is obviously deleting steps, and indicating how to fill them in. – Thomas Andrews Jun 11 '22 at 18:17
  • In any event, the word “quickly” does not have a technical meaning. The Euclidean algorithm is $$23=13\cdot 1+10\13=10\cdot 1+3\10=3\cdot 3+1\3=1\cdot 3+0.$$ The reversing is another four steps to get the answer. So it depends on what is meant by “quickly.” – Thomas Andrews Jun 11 '22 at 18:21
  • what is meant by reversing @ThomasAndrews – homosapien Jun 11 '22 at 18:25
  • $13x!+!23y = 379\iff \bmod 13!:\ {-}3y\equiv 2\equiv 15!\iff! y\equiv -5\equiv 8,,$ so $, x = (379!-!8(23))/13 = 15.\ $ As explained in the linked dupe, as above, solving that linear diophantine equation is equivalent to solving a linear congruence, for which there are many known methods (follow the links there). There is no need to first solve the case with RHS $= 1.\ $ Alternatively you can apply the extended Euclidean algorithm. – Bill Dubuque Jun 11 '22 at 18:52
  • For the book's way, as above: $\bmod 13!:\ {-}3y\equiv 1\equiv -12\iff y\equiv 4,,$ so $,x = (1-4(23))/12 = -7.\ $ It's $:!< 10$ seconds of mental arithmetic either way (but done the book's way you still need to scale by $379$, which is more work). – Bill Dubuque Jun 11 '22 at 18:58
  • 1
    From the Euclidean algorithm, you get $$\begin{align}1&=10+3\cdot (-3)\1&=10+(13+10\cdot(-1))(-3)\&=10\cdot4+13\cdot(-3)\1&=(23\cdot1+13\cdot (-1))\cdot4+13\cdot(-3)\&=23\cdot4+13\cdot(-7) \end{align} $$ This sort of reverses the Euclidean algorithm. – Thomas Andrews Jun 11 '22 at 19:01

1 Answers1

0

they used the Euclidean Algorithm to solve for $x=-7, y=4$ although they did not show it. here it is: First, $23=1\cdot 13+1\cdot 10, 13=1\cdot 10+1\cdot3, 10=3\cdot 3+1\cdot 1$, so we have: \begin{align} 1&= 10-3\cdot 3 \\ &= 10-3\cdot(13-1\cdot 10) \\ &= 4\cdot 10-3\cdot 13 \\ &= 4(23-1\cdot 13)-3\cdot 13 \\ &= 4\cdot 23-7\cdot 13. \end{align}

Since this pair is a solution to $13x+23y=1$, then multiplying both sides of the equation by $379$ gives you that the pair $x=-7\cdot 379, y=4\cdot379$ is a solution to $(*)$. Finally, to find a valid solution to your original problem, notice that $13\cdot23 -23\cdot 13 = 0$. So, if we add $23$ to $x$ and subtract $13$ from $y$ we will have another valid solution. To see this explicitly, $$(13\cdot23 -23\cdot 13) + 379(13\cdot-7+23\cdot4)= 0 + 379(13\cdot-7+23\cdot4)= 379\cdot 1= 379.$$ So we can add $c$ multiples of $23$ to $x$ and subtract multiples of $13$ from $y$ to get soltuions where both $x$ and $y$ are positive.

  • could you show me how they used the Euclidean algorithm to solve for $-7$ and $4$?? – homosapien Jun 11 '22 at 18:37
  • @HossienSahebjame to make sure you aren't just using this site to get solutions to hw problems, i think it is best if you figure this part out on your own. there are thousands of examples of the euclidean algorithm on the internet and therefore, you can simply adapt it to solve for solutions to the equation $13x+23y=1$. this answer was written to give you intuition for the implications of the solution to the equation given by the algorithm. – atul ganju Jun 11 '22 at 18:46
  • no I am teaching a course to computer engineers which requires some number theory and I am preparing lecture notes. I need to make sure I understand it first before teaching it. I tried rewriting the equations backwards but I don't get how they got -7 and 4. – homosapien Jun 11 '22 at 18:51
  • @HossienSahebjame ill take your word for it. – atul ganju Jun 11 '22 at 19:00
  • @Hossien If you insist on doing it the long way using the extended Euclidean algorithm as above, then you should always teach it in said forward form, since the above backward substitution form is notoriously error prone and is far less intuitive. You can find many worked examples (including errors!) in the "linked" posts here – Bill Dubuque Jun 11 '22 at 19:07
  • @amathguy Please strive not to post more (dupe) answers to dupes of FAQs, cf. recent site policy announcement here. – Bill Dubuque Jun 11 '22 at 19:08