How do I solve congruences with two variables and distinct moduli?

710 Views Asked by At

I'm interested in solving congruences such as $$x \equiv 4 \bmod{13}\\ y \equiv 7 \bmod{19}\\x \equiv y \bmod{6}$$In other words, linear congruences across two variables with distinct, coprime moduli. Notice that in this problem, two of the congruences involve only a single variable. I'd like a fast and simple way to find solutions. Any ideas?

I did stumble across this paper on a Multivariable version of the Chinese Remainder Theorem (https://arxiv.org/pdf/1206.5114.pdf), which might be helpful. I'm looking for something very simple which I can implement easily in real code.

1

There are 1 best solutions below

0
On

Let moduli be $m_1, \dots, m_k$. Compute $M=\mathrm{lcm}(m_1, \dots, m_k)$ and multiply the $i$-th congruence by $M/m_i$ to get the system of linear equations over the ring of integers modulo $M$.

This way your example $$\begin{cases} x\equiv 4\pmod{13}\\ y\equiv 7\pmod{19}\\ x\equiv y\pmod{6} \end{cases}$$ is turned into $$\begin{cases} 114x\equiv 456\pmod{1482}\\ 78y\equiv 546\pmod{1482}\\ 247x\equiv 247y\pmod{1482} \end{cases}$$ where all congruences are modulo $1482$.