3
$\begingroup$

What's the most straightforward way to ask Mathematica to find all solutions of an equation like

$$3x + 2y + 4z = 0 \pmod {11}$$

(for instance), where either $x$, $y$, $z$ can be considered to be integers in the range $-5\dots 5$, or equivalently they belong to the ring $Z/(11Z)$ of integers modulo $11$?

(I've tried a number of obvious things with no success.)

$\endgroup$

2 Answers 2

5
$\begingroup$
Solve[Mod[3 x + 2 y + 4 z, 11] == 0 &&
      -5 <= x <= 5 && -5 <= y <= 5 && -5 <= z <= 5, Integers]

(*    {{x -> -5, y -> -5, z -> -2},
       {x -> -5, y -> -4, z -> 3},
       {x -> -5, y -> -3, z -> -3},
       ...
       {x -> 5, y -> 5, z -> 2}}    *)

(121 solutions)

$\endgroup$
4
$\begingroup$

Solve[3 x + 2 y + 4 z == 0, Modulus -> 11] produces {{z -> 2 x + 5 y}} (as residue classes modulo 11).

$\endgroup$
4
  • $\begingroup$ Yes, multiplying 3x + 2y + 4z = 0 by 3 (in the field Z/11Z) gives -2x + 6y + z = 0, or in other words z = 2x + 5y. $\endgroup$ Commented Feb 22, 2021 at 6:25
  • $\begingroup$ Which is the set of solutions! Just like linear algebra over the field of real numbers, we have two free variables x and y, and the value of z is uniquely determined by them. In my opinion, this is a much better form than listing the 121 solutions one by one. $\endgroup$ Commented Feb 22, 2021 at 6:48
  • $\begingroup$ I agree, this is much better than what I proposed. $\endgroup$
    – Roman
    Commented Feb 22, 2021 at 12:38
  • 1
    $\begingroup$ I personally prefer Reduce[] for this: Reduce[3 x + 2 y + 4 z == 0, {x, y, z}, Modulus -> 11]. This highlights the fact that there is a parametric solution. $\endgroup$ Commented Feb 22, 2021 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.