# Solving a system of equations using modular arithmetic modulo 5

Give the solution to the following system of equations using modular arithmetic modulo 5:

$4x + 3y = 0 \pmod{5}$
$2x + y \equiv 3 \pmod{5}$

I multiplied $2x + y \equiv 3 \pmod 5$ by $-2$, getting $-4x - 2y \equiv -6 \pmod{5}$.

$-6 \pmod{5} \equiv 4 \pmod 5$

Then I added the two equations:

$4x + 3y \equiv 0 \pmod{5}$
$-4x - 2y \equiv 4 \pmod{5}$

This simplifies to $y \equiv 4 \pmod{5}$.

I then plug this into the first equation: $4x + 3(4) = 0 \pmod{5}$

Wrong work:

Thus, $x = 3$. But when I plug the values into the first equation, I get $2(3) + 4 \not\equiv 3 \pmod{5}$. What am I doing wrong?

EDIT:

Revised work:

$x = -3 \pmod{5} = 2 \pmod{5}$.
Now when I plug the values into the first equation, I get $2(2) + 4 \equiv 8 \pmod{5} \equiv 3 \pmod{5}$.

-

Sign error on substitution, it should be $x\equiv -3\pmod{5}$.

You had $4x+(3)(4)\equiv 0$, that is, $4(x+3)\equiv 0$. From this we get $x+3\equiv 0$, so $x\equiv -3\pmod{4}$.

Negative numbers are sometimes troublesome, so we may wish to rewrite as $x\equiv 2\pmod{5}$.

-
Thank you for the correction! –  user93172 Sep 5 '13 at 0:36
You are welcome. Once you have made a thousand more sign errors, you will be eligible to join my club. –  André Nicolas Sep 5 '13 at 0:38

There's also a "cheats" method available here. There are only $25$ possible values of $(x,y) \in (\mathbb{Z}_5)^2$. We can just check them one-by-one, and see which ones work.

We could do this by hand, or on a computer. In GAP:

for x in [0..4] do
for y in [0..4] do
if((4*x+3*y) mod 5=0 and (2*x+y) mod 5=3) then
Print([x,y],"\n");
fi;
od;
od;


returns the single solution $(x,y)=(2,4)$.

-
+Size(SymmetricGroup(IsPermGroup,1)) for using GAP. :-) –  Babak S. Sep 5 '13 at 0:58
Print(Concatenation([":",")"]),"\n"); –  Douglas S. Stones Sep 5 '13 at 1:19
+ Number(Cartesian([0..4],[0..4]),t->((4*t[1]+3*t[2]) mod 5=0 and (2*t[1]+t[2]) mod 5=3)); :-) –  Alexander Konovalov Sep 5 '13 at 8:40
One could also solve the system over $GF(5)$. First call m:=[[4,3],[2,1]]; v:=[0,3]; e:=Z(5)^0; and then List(SolutionMat(TransposedMat(m)*e,v*e),Int); –  Alexander Konovalov Sep 5 '13 at 8:48

It's the last step, where you're solving for $x$.

$4x + 12 \equiv 0 \Rightarrow 4x\equiv 3 \Rightarrow x\equiv 2$.

-
Thank you! I've corrected my mistake. –  user93172 Sep 5 '13 at 0:33

You may consult Maple as follows to get that $(2,4)$ is the only solution for the system.

[> msolve({2*x+y = 3, 4*x+3*y = 0}, 5);

{x=2,y=4}

-
You are becoming a "Maple Finatic" :-p (just teasing!) +1 –  amWhy Sep 5 '13 at 12:42
@amWhy: Yes, I am :-) –  Babak S. Sep 5 '13 at 13:36
@amWhy: I have the same one, Amy. :( –  Babak S. Sep 5 '13 at 14:54
@amWhy: That is so kind of you :) –  Babak S. Sep 5 '13 at 15:02