1

I know a bit about the Chinese Remainder theorem but what do I do in the case I was asked to solve a system of congruences such as this with two variables:

$3x + y = 7$ (mod 8)

$4x + 3y = 1$ (mod 8)

  • 1
    Welcome to Math Stack Exchange. What would you do if you had two equations to solve in $\mathbb R$ like those in $\mathbb Z/8\mathbb Z$? – J. W. Tanner Nov 15 '19 at 01:11

4 Answers4

3

Approach these equations as you would equations over $\mathbb R$.

Multiply the first by $3$ to get $x+3y\equiv5\pmod 8$.

Then subtract that from $4x+3y\equiv1\pmod 8$ to get $3x\equiv1-5\equiv9-5=4\pmod8$.

Multiply by the inverse of $3$ (which is $3\pmod8$) to get $x\equiv4\pmod 8$.

Now can you solve for $y$ given $3x+y\equiv7\pmod8$?

J. W. Tanner
  • 60,406
  • 1
    When you say to multiply the first one by 3, how did you get $x + 3y = 5$ (mod 8) – slayer6969 Nov 15 '19 at 01:24
  • 1
    $(3\times3)x+3y\equiv3\times7\pmod8\implies9x+3y\equiv21\pmod8\implies x+3y\equiv5\pmod8$ because $ 9\equiv1 $ and $21\equiv5\pmod8$ – J. W. Tanner Nov 15 '19 at 01:27
  • 2
    Ok thanks. I understand. – slayer6969 Nov 15 '19 at 01:29
  • Ok, so the approach these types of questions is to multiply one of the equations by a number and then add/subtract the second equation to eliminate one of the variables. Then solve the first variable like x in this case and then using the first variable, solve the second? Just like normal algebra. – slayer6969 Nov 15 '19 at 01:50
  • Just like normal algebra – J. W. Tanner Nov 15 '19 at 02:04
  • What if they are different mods? – slayer6969 Nov 15 '19 at 02:52
  • @slayer6969 Beware Generally you cannot "approach ... as you would over $\Bbb R$" because $\Bbb Z/8$ is not a field, so you have to be more careful, e.g. scaling by noninvertible elements (here even integers) does not yield equivalent equations (that is not done above so there is no problem, but it is a pitfall that deserves explicit emphasis). – Bill Dubuque Nov 15 '19 at 04:19
0

Solve the system of equations without the $\pmod 8$. You will get $x = 4, y = -5$.

Toby Mak
  • 16,827
  • Why can we just ignore the mod (8). I do agree that these solutions work, but would these work if the mod's were different for each equation? – slayer6969 Nov 15 '19 at 01:28
  • If you change the last equation to $4x+3y=9$ for example, you will get $x = \frac{12}{5}, y = -\frac{1}{5}$, which is equivalent to $x = \frac{12+8}{5} = 4, y = \frac{-1+8*2}{5} = 3$ modulo $8$. You basically have to solve $12+8x \pmod 5 \equiv 0, -1+8x \pmod 5 \equiv 0$ which you can do by taking the inverse of both sides. – Toby Mak Nov 15 '19 at 01:32
  • You can also use Bill Dubuque's technique on how to reduce these fractions. – Toby Mak Nov 15 '19 at 01:37
0

The first equation is in a form suggesting substitution method as you have $y$ with coefficient $1$:

  • $y \equiv 7-3x \pmod 8$

Plug this into the second equation and solve for $x$: $$4x + 3(7-3x) \equiv 4x +21 -9x \stackrel{21=16+5}{\equiv} -5x +5 \equiv 1 \pmod 8$$

Now, note that the $5^2 \equiv (24+1) \equiv 1 \pmod 8$. Using this you get $$\Leftrightarrow 5x \equiv 4 \pmod 8 \stackrel{\cdot 5}{\Leftrightarrow} \boxed{x =} 20 \equiv \boxed{4 \pmod 8}$$

Plugging this back into the equation $y \equiv 7-3x\pmod 8$ gives $$\boxed{y=} 7-3\cdot 4 \equiv -5 \equiv \boxed{3 \pmod 8}$$

0

Cramer's rule ($\rm\color{#0a0}{scale}$ by $\color{#c00}{\rm adjugate}$) works over any commutative ring (here $\Bbb Z/8 = $ integers $\!\bmod 8)$

$\qquad\quad\ \begin{align} \rm\color{#c00}{\begin{bmatrix}\rm 3 &\!\!\! \rm -1 \\ \!\!\rm -4 & \rm 3 \end{bmatrix}} {\bf \color{#0a0}\times} &\, \left\{\, \begin{bmatrix}\rm 3 & \rm 1 \\ \rm 4 & \rm 3 \end{bmatrix} \begin{bmatrix} \rm x \\ \rm y \end{bmatrix} \,\equiv\, \begin{bmatrix}\rm 7 \\ \rm 1\end{bmatrix}\, \right\}\\[.2em] \Longrightarrow &\,\qquad\qquad\, \begin{array}\ \rm\ 5\ x\ \equiv\, \ \ \rm \color{#c00}3\cdot 7 \color{#c00}{- 1}\cdot 1\, \equiv\ \ \ 20\iff x\equiv\, 4\\ \rm\ 5\ y\ = \rm \color{#c00}{-4}\cdot 7 + \color{#c00}1\cdot 3 \,\equiv -25\!\iff y\equiv -5\end{array}^{\phantom{|}} \end{align}$

$ \begin{align}{\rm using}\ \ \ \rm\color{#c00}{\begin{bmatrix}\rm d &\!\!\! \rm -b \\ \!\!\rm -c & \rm a \end{bmatrix}} {\bf \color{#0a0}\times} &\, \left\{\, \begin{bmatrix}\rm a & \rm b \\ \rm c & \rm d \end{bmatrix} \begin{bmatrix} \rm x \\ \rm y \end{bmatrix} \,=\, \begin{bmatrix}\rm X \\ \rm Y\end{bmatrix}\, \right\}\\[.2em] \Longrightarrow &\,\qquad\qquad\, \begin{array}\ \rm\Delta\ x\ =\, \ \ \rm \color{#c00}d\ X \color{#c00}{- b}\ Y \\ \rm\Delta\ y\ = \rm \color{#c00}{-c}\ X + \color{#c00}a\ Y \end{array}^{\phantom{|}} ,\ \ \ \ \rm \Delta\ :=\ \color{#c00}{ad-bc} \end{align}$

Beware $ $ The determinant $\Delta = 5\,$ is invertible $\!\bmod 8$ so we can cancel it to (uniquely) solve for $x$ and $y$. If it is not coprime to the modulus then it is not invertible so we need to be more careful, and there may be zero or multiple solutions. The same caveat holds if you instead perform (Gaussian) elimination, where scaling an equation need not yield an equivalent equation if the scale factor is not invertible. Thus you cannot generally "solve as you do in $\Bbb R$" as suggested elsewhere on this page (but that is true for prime moduli $p$ where $\,\Bbb Z/p\,$ is a field like $\Bbb R,\,$ i.e. nonzero elements are invertible).

Bill Dubuque
  • 272,048