6

I'm given a system of congruences and want to apply the Chinese remainder theorem (CRT) on it, but the greatest common divisor (GCD) of the moduli is not $1$.

Well, I need to reduce the system, such that the GCD is $1$, but I don't know how the "reducing" works. I mean I need an explanation.

I found an example, but don't get how they magically transform it from

$$x \equiv 1 \mod 108$$ $$x \equiv 13 \mod 40$$ $$x \equiv 28 \mod 225$$

to $$x \equiv 1 \mod 27$$ $$x \equiv 5 \mod 8$$ $$x \equiv 3 \mod 25$$

I see that $$108 = 2^2 \times 3^3$$ $$ 40 =5 \times 2^3$$ $$225=3^2 \times 5^2$$

but not sure when and how they used it... thanks for the help!

Bill Dubuque
  • 272,048
  • $a \equiv b \mod km \implies a = b + Nkm \implies a = b + (Nk)m \implies a \equiv b \mod m$. (Are you giving yourself a dopeslap?) – fleablood May 23 '17 at 23:34

4 Answers4

2

Essentially you have to figure out congruences that mean kind of the same thing.

For example, if $x \equiv 1 \bmod 108$, then $x \equiv 1 \bmod 3$ as well. However, you don't have to divide $108$ that much, since dividing out the $4$ to get $x \equiv 1 \bmod 27$ is enough to make the first modulus coprime to the other two moduli.

Now you just need to to make the moduli $40$ and $225$ coprime. You could divide the $25$ out of $225$ and then the third modulus is coprime to the second, but not to the first.

Therefore the most straightforward choice at this point is to divide the $5$ out of $40$, and divide the $9$ out of $225$, giving you $8$ and $25$ for the second and third moduli.

But watch out: since $13 > 8$ and $28 > 25$, you need to change those two remainders. Well, technically you don't have to, but some implementations of the algorithm could be thrown off and fail to deliver the correct result, or any result at all.

Thus $x \equiv 13 \bmod 40$ becomes $x \equiv 5 \bmod 8$ (since $13 - 8 = 5$) and $x \equiv 28 \bmod 225$ becomes $x \equiv 3 \bmod 25$ (since $28 - 25 = 3$).

To check your answers in Wolfram Mathematica or Wolfram Alpha: do ChineseRemainder[{1, 13, 28}, {108, 40, 225}] and compare the results to ChineseRemainder[{1, 5, 3}, {27, 8, 25}] (depending on circumstances beyond your control, Wolfram Alpha may fail to give a result when the moduli are not coprime).

$x = 2053$, since $2053 = 19 \times 108 + 1 = 51 \times 40 + 13 = 9 \times 225 + 28$. Also $2053 = 76 \times 27 + 1 = 256 \times 8 + 5 = 82 \times 25 + 3$.

(I just wanted to try that "invisible until hover" text that I see on so many answers on this site).

Mr. Brooks
  • 1,098
2

Reducing is trivial:

If $a \equiv b \mod n$ then $a \equiv b \mod k$ for all $k|n$.

Just think about it......

=======

$x \equiv 1 \mod 108 \implies x= 108k + 1 = 27(4k) + 1 \implies x \equiv 1 \mod 27$.

$x \equiv 13 \mod 40 \implies x = 40k + 13 = 8(5k) + 13 \implies x \equiv 13 \equiv 5 \mod 8$. etc.

=======

It's going the other way that requires (minor) stipulation.

If $a \equiv b \mod k$ then $a \equiv b + ck \mod n$ for any $n$ a multiple of $k$ and $c$ is some integer; (exactly which integer is not necessarily known).

====

So $x \equiv 1 \mod 3^3*2^2$

$x \equiv 13 \mod 2^3*5$

$x \equiv 28 \mod 5^2*3^2$

Pick the largest of the mutually prime factors: $3^3;2^3;5^2$

So

$x \equiv 1 \mod 3^3$

$x \equiv 13\mod 2^3$

$x \equiv 28 \mod 2^5$.

fleablood
  • 124,253
2

Below we sketch three methods to solve congruence systems with noncoprime moduli.


Key idea: use $\:\!\bf \color{darkorange} C\!=$ CRT to split the congruences into equivalent congruences to prime powers, then eliminate redundant congruences (shown as up and down arrow implications below), e.g. note: $\, \color{#c00}{x\equiv 5\pmod{\!2^3}}\ \Rightarrow\ \color{#b80}{x\equiv 1\pmod{\!2^2}},\,$ so the latter is redundant and can be deleted.

$\!\begin{array}{lll} x\,\equiv\,1 \pmod{\!\color{#b80}{2^2}\cdot \color{#0a0}{3^3}}\!\!\!\!\overset{\color{darkorange}{\bf C}\!\!}\iff &\!\!\!\!\!\!\color{#b80}{x\equiv1 \pmod{\!2^2}}, &\!\!\!\!\!\ \color{#0a0}{x\equiv 1\pmod{\!3^3}}\\[-0.5em] &\! \Uparrow & \ \:\!{||}\\[-1em] x\equiv 13 \pmod{\!\color{#c00}{2^3}\cdot 5}\smash[t]{\overset{\color{darkorange}{\bf C}\!\!}\iff} &\!\!\!\!\!\!\color{#c00}{x\equiv 5 \pmod{\!2^3}}, \rlap{\ .\ .}&\:\! \ \raise 0.03em{||}\ .\ .\ .\ .\ .\ .\ .\ . &\!\!\! x\equiv 3\pmod{\!5}\\[-.5em] & & \,\:\!\large \raise 0.1em{\Downarrow} & \,\,\:\!\Uparrow\\[-.2em] x\equiv28\pmod{\!3^2\cdot \color{#90f}{5^2}}\!\smash{\overset{\color{darkorange}{\bf C}}\iff}&\!\!\!\!\!. \ .\ .\ .\ .\ .\ .\ .\ .\ .&\!\!\!\!x\equiv1\pmod{\!3^2}, &\!\!\!\color{#90f}{x\equiv 3\pmod{\!5^2}} \end{array}$

We get an equivalent system by deleting congruences implied by $\!\color{#0a0}{\bmod 3^3}$ & $\!\color{#90f}{\bmod 5^2},\,$ viz.

$$\begin{align} &\color{#c00}{x\equiv 5\!\!\pmod{2^3}}\\ &\color{#0a0}{x\equiv 1\!\!\pmod{3^3}}\\ &\color{#90f}{x\equiv 3\!\!\pmod{5^2}} \end{align}\qquad\qquad$$

Since the moduli are now pairwise coprime we can now apply (Easy) CRT to solve it.

The above implications are a special case of: congruences persist mod factors of the modulus (above the factors have the simple form $\,p^k\mid p^{k+n},\,$ since the moduli are prime powers).


Or we can avoid expensive factorization of the moduli by instead applying General Easy CRT, which handles noncoprime moduli. As explained there, using such we can solve a system of congruences by repeatedly replacing any pair of congruences by an equivalent congruence.


Or scale all congruences to equivalent congruences $\!\bmod 5400$ (= moduli lcm), then solve that system using the fractional extended Euclidean algorithm (see the end of this answer).

$$\begin{align} &\color{0a0}{x\equiv 13\!\!\!\pmod{\ \ 40}}\\ &\color{c00}{x\equiv\ \ 1\!\!\!\pmod{108}}\\ &\color{90f}{x\equiv 28\!\!\!\pmod{225}} \end{align}\iff\!\!\!\!\!\! \begin{array}{l} &\color{0a0}{135x\equiv 1755\pmod{5400}}\\ &\ \ \color{c00}{50x\equiv 50\ \ \ \ \pmod{5400}}\\ &\ \ \color{90f}{24 x\equiv 672\ \ \pmod{5500}} \end{array}\qquad\qquad\qquad$$

$\ \iff \bmod 5400\!:\ x\equiv \dfrac{1755}{135} \overset{\large\frown}\equiv \dfrac{50}{\color{90f}{50}}\overset{\large\frown}\equiv \dfrac{672}{24}\overset{\large\frown}\equiv \dfrac{-1294}2\overset{\large\frown}\equiv\:\! \bbox[5px,border:1px solid #c00]{\dfrac{2053}1}$

Bill Dubuque
  • 272,048
1

The primes that divide at least one of the three moduli are $2$, $3$ and $5$.

The highest power of $2$ in any of them is $2^3 = 8$, which divides $40$. Given that $x \equiv 13 \mod 40$, $x \equiv 13 \equiv 5 \mod 8$. You also have $x \equiv 1 \mod 108$ which implies $x \equiv 1 \mod 4 (=2^2)$, and this is not a problem since $5 \equiv 1 \mod 4$.

Similarly, the highest power of $3$ is $3^3 = 27$; $x \equiv 1 \mod 108$ so $x \equiv 1 \mod 27$, and this is compatible with $x \equiv 28 \mod 225$ since $28 \equiv 1 \mod 3^2$.

Finally, the highest power of $5$ is $5^2 = 25$; $x \equiv 28 \mod 225$ implies $x \equiv 28 \equiv 3 \mod 25$, and this is compatible with $x \equiv 13 \mod 40$ because $13 \equiv 3 \mod 5$.

Robert Israel
  • 448,999