2

$$x \equiv -7 \mod 13$$ $$x \equiv 39 \mod 15$$

I need to find the smallest x for which these equations can be solved. I've been always doing this using Chinese Reminder Theorem, but it seems that it doesn't work here, I'm not sure why though. Let's see:

$N = 13*15 = 195$
$N_{1} = \frac{195}{13} = 13$
$N_{2} = \frac{195}{15} = 15$

$GCD(13, 13) = 1*13 + 0*13$
$GCD(15,15) = 1*15 + 0*15$

$$x = 1 * (-7) * 13 + 1 * 39 * 15 = 480$$


The answer however is supposed to be $x = 84$...What's wrong?

khernik
  • 1,369

3 Answers3

2

The way I usually go about these is to solve the two systems $$ \mbox{$\begin{align} x_{13}&\equiv1\pmod{13}\\ x_{13}&\equiv0\pmod{15} \end{align}$} \qquad\text{and}\qquad \begin{align} x_{15}&\equiv0\pmod{13}\\ x_{15}&\equiv1\pmod{15} \end{align} $$ Then combine these to get the solution to the equation given. These can both be solved at once using the Euclid-Wallis Algorithm: $$ \begin{array}{r} &&1&6&2\\\hline 1&0&1&-6&13\\ 0&1&-1&7&-15\\ 15&13&2&1&0\\ \end{array} $$ This says that $(-6)15+(7)13=1$ which immediately gives $x_{13}\equiv(-6)15\pmod{195}$ and $x_{15}\equiv(7)13\pmod{195}$. The solution to the original question is $$ \begin{align} x &\equiv-7x_{13}+39x_{15}\\ &\equiv84\pmod{195} \end{align} $$ Caveat: in the case of two equations as above, this only requires one application of the Euclidean algorithm. However, in the case of three or more equations, we need to apply the Euclidean algorithm once per modulus. For example, to solve $$ \begin{align} x&\equiv 1\pmod{3}\\ x&\equiv 2\pmod{5}\\ x&\equiv 4\pmod{7} \end{align} $$ we would need to solve each of $$ \mbox{$\begin{align} x_3&\equiv1\pmod{3}\\ x_3&\equiv0\pmod{35} \end{align}$} \quad\text{and}\quad \mbox{$\begin{align} x_5&\equiv1\pmod{5}\\ x_5&\equiv0\pmod{21} \end{align}$} \quad\text{and}\quad \begin{align} x_7&\equiv1\pmod{7}\\ x_7&\equiv0\pmod{15} \end{align} $$ using the Euclid-Wallis Algorithm.

robjohn
  • 345,667
  • Hi @Robjohn : again Euclid-Wallis...sigh...did you know three out of the four sites google posts when asked about this are yours? Where did you learn from this? Some book, paper...which either google missed or it is out of the web...? I still cannot understand the algorithm: i just can't see how that matrix-like setup is constructed, though you tried to help before (remember?). If you have some source I'd appreciate it. – DonAntonio May 21 '13 at 16:48
  • @DonAntonio: I expanded the explanation in this answer. I tried to go step by step. – robjohn May 21 '13 at 17:14
  • @DonAntonio: I just went back and added color to the descriptive text above the step by step instructions. – robjohn May 21 '13 at 17:37
  • I very much appreciate this, but tell me: where you write in blue and green "write down the floor of the quotient of the base of the previous column divided into the base of the column before that", shouldn't it be "the quotient of the base of two columns before divided by the base of the column before..." ? – DonAntonio May 21 '13 at 19:06
  • @DonAntonio: $6$ divided by $3$ is the same as $3$ divided into $6$. See this ELU thread. I worried about possible confusion from "divide into" and "subtract from", but I thought that counting back multiple columns made the description sound even more complicated. – robjohn May 21 '13 at 19:19
  • I know 6 divided by 3 is the same as 3 divided into 6...and yet the wording succeeded to confuse me. Perhaps it's only me, but maybe actually numbering the columns from left to right (col. 1, col. 2 and etc.) would help. Anyway,I already got it (BRAVO!!!) and I very much thank you once again. This is a very nice thing and, obviously, I never heard of it before you mentioned it. – DonAntonio May 21 '13 at 19:28
  • One more question, @robjohn : in your answer above, how did you come up with $,x=-7x_{13}+39x_{15}=84\pmod{195},$ by means of the E-W algorithm ? Or you just had to calculate otherwise (i.e., without the algorithm) what the minimal positive solution is? – DonAntonio May 21 '13 at 19:39
  • @Don What Rob calls the Euclid-Wallis algorithm is better-known as the augmented-matrix form of the extended Euclidean algorithm. It executes Euclid's algorithm for $\gcd(a,b),$ augmented by columns that keep track of each remainders linear representation in terms of $,a,b.,$ See this post for a detailed exposition of the method. See also the Wikipedia article on the extended Euclidean algorithm. – Key Ideas May 21 '13 at 20:36
  • @DonAntonio: It is basically just the Euclidean algorithm (divide, use the remainder as the new divisor and bring the old divisor down as the new dividend, repeat) with the addition of the bookkeeping that I believe John Wallis used to compute continued fractions from top to bottom, rather than the naive bottom to top. – robjohn May 21 '13 at 20:46
  • @DonAntonio: $x\equiv-7x_{13}+39x_{15}$ because of the first two sets of equations after the first paragraph ($-7$ times the set on the left plus $39$ times the set on the right gives the original problem). Otherwise, I just plugged in $x_{13}$ and $x_{15}$ and computed and reduced mod $195$. – robjohn May 21 '13 at 21:25
1

First, you can check your answer by taking it mod $13$ and $15$ (it's not right). Second, there are several formulas for applying the CRT; however the method you're using doesn't agree with any of them. It's difficult to find the place where your method differs from the one you were given, without knowing the latter.

The most common formula to solve $x\equiv x_1\pmod{a_1}, x\equiv x_2\pmod{a_2}$ is $$x\equiv x_2a_1 (a_1)^{-1} + x_1 a_2(a_2)^{-1}$$

Where $(a_1)^{-1}$ is computed modulo $a_2$, and vice versa. In this case, $a_1=13, a_2=15$. We have $(a_1)^{-1}=7, (a_2)^{-1}=7$ by coincidence, so $x=(39)13(7)+(-7)15(7)=2814$, which is equivalent to $84$, modulo $13\times 15=195$.

vadim123
  • 82,796
1

Below is a correct form of that version of the CRT = Chinese Remainder Theorem

$ \begin{eqnarray}x\equiv \color{#0a0}{-7}\!\!\pmod{\color{#c00}{13}}\\ x\equiv\ \color{#c00}{39}\!\!\pmod{\color{#0a0}{15}}\end{eqnarray} \!\iff x \equiv 15\left[\color{#0b0}{\dfrac{-7}{15}}\ {\rm mod}\ 13\right] + 13\left[\color{#c00}{\dfrac{39}{13 }}\ {\rm mod}\ 15\right] \pmod{13\cdot 15}$

Computing the $\rm\color{#0b0}{frac}\color{#c00}{tions\!\!:}$ $ $ mod $13\!:\, \color{#0b0}{\dfrac{-7}{15}\equiv \dfrac{6}2\equiv 3},\, $ so $\ x \equiv 15\cdot \color{#0b0}3\! +\! 13\cdot \color{#c00}3\equiv 84\pmod{\!195}$

Bill Dubuque
  • 272,048
Key Ideas
  • 4,224