Solving Chinese Remainder Theorem

486 Views Asked by At

If $x = am + k = bn - k$ for known $a,b,k$ and $\gcd(a,b)$, how to solve for $x$ using Chinese Remainder Theorem?

2

There are 2 best solutions below

11
On

Write $\text{g.c.d.}(a,b)=g$. And $a=ga'$, $b=gb'$. Further suppose that $ar+bs=g$, by Bézout's identity.
Firstly, for $x$ to solvable, it needs and it suffices that $g\mid 2k$.
When $g\mid k$, just divide out and suppose that $g=1$, so that $ar+bs=1$. Then $bsk-akr$ is easily seen to be congruent to $k\pmod a$, and $\equiv -k\pmod b$. So this is one $x$.
When $g=2$, then $ar+bs=2$, so that $ark+bks=2k$, that is to say, $-ark+k=bks-k$ is one $x$.
So we have found all solutions.
If error occurs, never let it go: please tell me, thanks in advance.

0
On

From the initial equations, $$ x \equiv k \pmod a\\ x \equiv -k \pmod b$$ By the chinese remainder theorem, when (a,b)=1 $$\mathbb{Z}_{a*b} \cong \mathbb{Z}_{a} \times \mathbb{Z}_b$$ The actual solution for x is of the form x+abt for some nonnegative integer t, but it's assumed that the wanted solution is when t=0. In other words, we're looking for the solution such that $$ 0\leq x \lt ab$$ This also implies that the solution we want has $$m \lt b$$ Substituting x=am+k into the second congruence and solving, $$am+k \equiv -k \pmod b\\ a^{-1}am\equiv m\equiv a^{-1}* -2k \pmod b$$ Since m < b, this gives m.
(Non-units could be a problem here if (a,b)≠1 )


In the above comment's case, a=8 and b=24, the Chinese remainder is not going to help since its general form is in terms of the intersection of the ideals.
$$R /(a) \cap (b) \cong R/(a) \times R/(b) $$ $$(8) \cap (24) = (24) $$ and so this could only give an answer (mod 24). The congruency (mod 24) is part of the given and does not help.