1

I am trying to find all integers that give remainders 1,2,3 when divided by 3,4,5 respectively. So I start defining $$a_1=1, a_2=2, a_3=3,$$$$ m_1=3, m_2=4, m_3=5,$$$$ m_1m_2=12, m_1m_3=15, m_2m_3=20,$$$$ m=60$$ All the moduli are pairwise coprime, so by the Euclidean Algorithm $$12x+5y=1\Rightarrow x=-2, y=5.$$ $$15x+4y=1\Rightarrow x=-1, y=4.$$ $$20x+3y=1\Rightarrow x=-1, y=7.$$ Therefor a solution should be $$20\cdot(-2)\cdot1 +15\cdot (-1)\cdot 2+12\cdot (-1)\cdot 3=-40-30-36=-106$$ But under mod 60, this implies a solutions should be of the form, $60t+14$. But it is not. THis is not right. Why did this technique not work?

Bill Dubuque
  • 272,048
Lalaloopsy
  • 1,853

3 Answers3

2

Hint $\ 3,4,5\mid x+2\!\!\overset{\rm\color{#90f}U\!\!}\iff \overbrace{{\rm lcm}(3,4,5)}^{\large 60}\mid x+2 \iff {\rm mod}\ 60\!:\,\ x\equiv -2\equiv 58$

where we used $\,\rm\color{#90f}U = $ lcm Universal Property. To find your error(s), check the answer mod $\,3,4,5,\,$ e.g. mod $\,3\!: x \equiv 20(-2)\equiv 2,\,$ not $1$. Looks like you mixed up the inverses in the final formula.

Remark $ $ Above I applied a simple reduction to the constant case optimization of CRT. $ $ If $\,x\equiv a_i\pmod {m_i}$ and $\,\color{#c00}{a_i - m_i = c}\,$ is constant (independent of $i),\,$ the system reduces to a simple constant case of CRT $\,\ x\equiv \color{#c00}{a_i \equiv m_i+c} \equiv c\pmod {m_i}.\,$ Therefore $$ x\equiv c\!\!\!\pmod {m_i}\iff m_i\mid x\!-\!c\!\!\overset{\rm\color{#90f}U\!\!}\iff {\rm lcm}\{m_i\}\mid x\!-\!c\iff x\equiv c\!\!\pmod{{\rm lcm}\{m_i\}}$$ Further examples of this and related optimizations can be found in prior posts.

To help avoid such errors, it might help to understand better the key use of linearity at the heart of the standard Chinese Remainder Theorem [CRT] formula.

$\quad \begin{eqnarray} x\, =\, &a&\!\color{#0a0}{\overbrace{(4\cdot 5\ y_1)}^{\large \equiv\, 1\ ({\rm mod}\ \color{#c00}3)}} \,+\, &b& \overbrace{(\color{#c00}3\cdot 5\ y_2)}^{\large \equiv\, 1\ ({\rm mod}\ 4)}\, +\, &c&\overbrace{(\color{#c00}3\cdot 4\ y_3)}^{\large \equiv\, 1\ ({\rm mod}\ 5)}\quad {\bf [CRT]}\\ \\ \Rightarrow\ \ x\,\equiv\, &a&\ ({\rm mod}\ \color{#c00}3),\ \ x\equiv &b&\ ({\rm mod}\ 4),\ \ x\equiv &c&\ ({\rm mod}\ 5)\\ \end{eqnarray}$

because, $ $ e.g., $\ $ mod $\ \color{#c00}3,\,$ the 2nd and 3rd summands are $\equiv 0,\,$ both having factors of $\,\color{#c00}3.\,$

Hence $\ x\,\equiv\, a\,\color{#0a0}{(4\cdot 5\ y_1)}\equiv a\color{#0a0}{(1)} \equiv a\,\ ({\rm mod}\ 3),\, $ as desired. $ $ Similarly $ $ mod $\,4\,$ and $\,5.$

The key idea is that the braced terms are $\equiv 1$ mod one modulus, and $\equiv 0 $ mod all others. More clearly, if we write the system in vector form $\ x\equiv (a,b,c)\,$ mod $\,(3,4,5)$ then $\rm\,[CRT]$ becomes

$\quad x\, :=\, a\,\color{#0a0}{(1,0,0)} + b\,(0,1,0) + c\,(0,0,1)\equiv (a.b,c)\ $ as desired. $\qquad [\bf Linearity]$

by the green term $\,\color{#0a0}{g \equiv 1}\ ({\rm mod}\ 3),\ \color{#0a0}{g\equiv 0}\ ({\rm mod}\ 4),\ \color{#0a0}{g\equiv 0}\ ({\rm mod}\ 5),\ $ i.e. $\ \color{#0a0}{g\equiv (1,0,0)}\ {\rm mod}\ (3,4,5),\ $ and similarly for $\,(0,1,0)\,$ and $\,(0,0,1).$

Thus once we compute the solutions for the "basis" vectors $(1,0,0),\ (0,1,0),\ (0,0,1)$ we can exploit [Linearity] to generate the general solution as a linear combination of these solutions.

The innate algebraic structure will be clarified if you later study abstract algebra, where you will learn the ring theoretic view of CRT, and vector spaces and modules.

Bill Dubuque
  • 272,048
  • I know the answers, but the technique I used above worked for numerous other examples. Why is it not working for me this time? – Lalaloopsy Jul 08 '14 at 14:24
  • Can you explain more about this technique you are referring to? Does it come from a book? – Nicky Hekster Jul 08 '14 at 14:28
  • Yes, from Niven. The technique is to form a linear combination $\sum_{i=1}^n{\frac{m}{m_i}b_ia_i}$, where $\frac{m}{m_i}b_i\equiv 1\pmod{m_i}$. I found the $b_i$ using linear combinations $m_im_jx+m_ky=1$. I then set $x=b_i$. – Lalaloopsy Jul 08 '14 at 14:35
  • @Nicky If $,x\equiv a_i\pmod {m_i}$ and $,\color{#c00}{m_i - a_i = c},$ is constant (doesn't depend on $i),,$ then the system reduces to a simple constant case of CRT $,\ x\equiv \color{#c00}{a_i \equiv m_i-c} \equiv -c\pmod {m_i}.,$ Above $,c = 2.\ \ $ – Bill Dubuque Jul 08 '14 at 14:40
  • @Lalaloopsy Nicky is not asking about that general form of CRT but, rather, the constant-case optimization that I applied in my answer. – Bill Dubuque Jul 08 '14 at 14:40
1

About the error: A couple of numbers got transposed. It should be $(20)(-1)(1)+(15)(-1)(2)+(12)(-2)(3)$.

André Nicolas
  • 507,029
  • I went back and saw where I made my mistake. I looked at each $b_i$ and realized they were with the wrong modulus. Thank you. – Lalaloopsy Jul 08 '14 at 14:49
  • 1
    You are welcome. It is one of those slips that once made is hard to spot. – André Nicolas Jul 08 '14 at 19:25
  • Yeah, I set my $b_1$ as the integer $x$ in $12x+5y=1$, but for the rest of the problem I defined $m_1=3, $and $m_3=5$. So my original $b_1$ should have been $b_3$. – Lalaloopsy Jul 09 '14 at 13:05
1

Another, more direct way of solving this runs as follows. You are looking at $$x \equiv 1 \text{ mod } 3$$ $$x \equiv 2 \text{ mod } 4$$ $$x \equiv 3 \text{ mod } 5.$$ Now put $x=1+3k$ and mod this by $4$. Then $2\equiv 1 +3k \text{ mod } 4$, so $k\equiv -1 \text{ mod } 4$, say $k=4l-1$, hence $x=-2+12l$. Now take the third equation into account. Then $3 = -2+12l\text{ mod } 5$, which is equivalent to $l \equiv 0 \text{ mod } 5$, say $l=5m$. So, finally $x=-2+60m$, whence $x\equiv -2\equiv58 \text{ mod } 60$.

Nicky Hekster
  • 49,281