0

Consider the following congruence equations:

$$ax\equiv b(mod m)$$

$$cx\equiv d(mod n)$$

How do we find a general solution? My idea is that $ax\equiv b(mod m)$ is the same as saying there is some $k$ for which $ax-b=km$ and similarly for the second equation but I can't find a general solution

Bill Dubuque
  • 272,048
  • The first dupe tells you how to reduce it to an equivalent system with monic congruences, i.e. with lead coefs $,a\equiv 1\equiv c,,$ and the second dupe tells you how to solve that using General Easy CRT. – Bill Dubuque Mar 03 '22 at 15:44

2 Answers2

0

First you need to know that each one of the congruences is solvable. In order to do so, we need to assume that $$ \gcd(a,m)\mid b\quad\text{and}\quad \gcd(c,n)\mid d $$ Now, under these condtions, solve each one of them (the first has $\gcd(a,m)$ solutions modulo $m$ and the second has $\gcd(c,n)$ solutions modulo $n$). Suppose we get $$ \begin{cases} x\equiv A\pmod{m}\\ x\equiv B\pmod{n}\\ \end{cases} $$ Now, the last syste is solvable iff $$ \mathrm{gcd}(m,n)\mid A-B $$

Example: let us solve
$$ \begin{cases} 4x\equiv 2\pmod{6}\\ 2x\equiv 4\pmod{8}\\ \end{cases} $$ Solve each one of them: $$ \begin{cases} x\equiv 2,5\pmod{6}\\ x\equiv 2,6\pmod{8}\\ \end{cases} $$ Next solve $$ \begin{cases} x\equiv A\pmod{6}\\ x\equiv B\pmod{8}\\ \end{cases} $$ where $A\in\{2,5\}$ and $B\in\{2,6\}$.

boaz
  • 4,783
0

We are given :

$ax\equiv b \pmod{m}$

$cx \equiv d \pmod{n}$

Let's denote $a^{-1}$ to mean the integer, should it exist, such that $aa^{-1}\equiv1 \pmod {m}$. Similarly, $cc^{-1}\equiv 1 \pmod{n}$. Note these inverses don't always exist.

$aa^{-1}\equiv 1 \pmod m\implies mp=aa^{-1}-1\implies aa^{-1}-mp=1$

So we only have a inverse if $gcd(a,m)=1$. By similar argument we also need $gcd(c,n)=1$.

Given those equations are satisfied, $a^{-1}$ and $b^{-1}$ can be found by Bezout's Identity or Euclid's GCD Algorithm.

Rewrite the congruences as:

$x\equiv ba^{-1} \pmod{m}$

$x \equiv dc^{-1} \pmod {n}$

From the first equation we have $x-ba^{-1}=mp\implies x=mp+ba^{-1}$ for some $p$. Place that value of $x$ into the second congruence:

$x \equiv dc^{-1} \pmod {n}\implies mp+ba^{-1}-dc^{-1}=nq$ for some $q$.

$\implies ba^{-1}-dc^{-1}=nq-mp$

This equation has solutions iff $gcd (m,n)|(ba^{-1}-dc^{-1})$.

Using Bezout's Identity again, find $p'$, $q'$ so that $nq'-mp'=gcd(m,n)$.

Then $p=p'(ba^{-1}-dc^{-1})/gcd(m,n)$. There is a similar expression for $q$.

Plug these values into the expression for $x$, reckoning $\pmod{lcm(m,n)}$ and one finds the desired solutions for $x$.

This is essentially a rehas of The Chinese Remainder Theorem.

TurlocTheRed
  • 5,683