I'm following the tutorial of an online calculator to solve congruence equations

I'm doing the same as they are doing but I never get the same result, I don't know what I'm doing wrong.

the tutorial http://www.a-calculator.com/congruence/#faq-formula

$28x\equiv 14 \ $mod $6$

$28$ mod $6$ and $14$ mod $6$ I get

a = $4$ and b = $2$

the linear combination of the $gcd(4,6) =$ $4(-1) + (1)6 = 2$

putting into the formula I get

$\begin{equation*} x_0 = \frac{2(-1)}{2} \; ( \text{mod} \; 6) \end{equation*} = 5$

general solution \begin{equation*} x_n = 5 + \frac{n(6)}{2} \; ( \text{mod} \; 6) \end{equation*}

the final answer is

General form of solutions: 2 + 3k.

Solutions for x less than 6: 2,5.
  • 1
    $\begingroup$ You cannot generally use division with congruence equations. $\endgroup$ – Elliot G Aug 22 '17 at 22:41
  • 1
    $\begingroup$ you can convert congruences into algebra ( sometimes with multiple variables) see math.stackexchange.com/questions/2401795/… @ElliotG I disagree to some extent, you just have to be very careful. in this case you can reduce to $14x \equiv 7 \bmod 3$ which then converts down to $2x\equiv1\bmod 3$ which then can give you the result. $\endgroup$ – user451844 Aug 22 '17 at 23:11
  • 1
    $\begingroup$ your answer is equivalent. The set all numbers that can be represented as 5+3k is the same set as the set that can be represented 2+3k. But rather than memorizing formulae, you should really be trying to understand the algebra. $\endgroup$ – Doug M Aug 22 '17 at 23:28
  • $\begingroup$ @DougM You are right, but I don't have much time left to learn such a complex thing, but anyways, thanks. $\endgroup$ – Goun2 Aug 22 '17 at 23:36
  • 1
    $\begingroup$ @hjx it's as easy as 5+3x = 2+3(x+1) $\endgroup$ – user451844 Aug 22 '17 at 23:39

First of all you can take all the coefficients down by congruence with the modulus.

$$28x\equiv 14 \bmod 6 \quad\to\quad 4x\equiv 2\bmod 6$$

Note that here, in concept, you are not dividing by $7$ - you are taking $28\bmod 6 $ and $14\bmod 6$ (even though the effect is the same).

Then you can put aside the common factor of $2$ from coefficients and modulus (although you may need to bring it back for the solution eventually):

$$4x\equiv 2 \bmod 6 \quad\to\quad 2x\equiv 1\bmod 3$$

Now, by examination, $x\equiv 2\bmod 3$ meaning - if you need to present the result $\bmod 6$ - $x\equiv \{2,5\} \bmod 6$, as per your text book.

Rather than a case where you can solve this last step "by examination" you may need to explicitly find the multiplicative inverse (and in this case that is what the equation amounts to anyway). For small moduli this may be an easy search; in general you can use the extended Euclidean algorithm.

  • $\begingroup$ Since your arrows are unidirectional, your deductions are only necessary but not sufficient conditions on solutions. In fact the reverse directions hold too, but you need to explicitly state that if you want to deduce the candidates are actually solutions without having to verify that. $\endgroup$ – Bill Dubuque Aug 22 '17 at 22:49
  • $\begingroup$ Why doesn't the given formula $\begin{equation*} x_0 = \frac{bp}{\text{gcd}(a, m)} \; ( \text{mod} \; m). \end{equation*}$ give the $x_0$ as 2 ? $\endgroup$ – Goun2 Aug 22 '17 at 23:00
  • $\begingroup$ @BillDubuque I'm indicating process rather than formal logical linkages with the arrows, which is why I drew them as single-stemmed. But apologies for any confusion. $\endgroup$ – Joffan Aug 22 '17 at 23:18
  • $\begingroup$ @hjx your formula has $x_{-1}=2$, so that solution is available. You could have got $x_0=2$ by using $2\cdot4 +(-1)\cdot 6 = 2$ for the gcd linear combination $\endgroup$ – Joffan Aug 22 '17 at 23:22
  • $\begingroup$ Thanks, Could you please explain this part ? Now, unless gcd(a,m) evenly divides b there won't be any solutions to the linear congruence. Though if it does, our first solution is given by $\endgroup$ – Goun2 Aug 22 '17 at 23:40

$$28x\equiv 14\mod 6$$ means $$6|28x-14$$

Since $28x-14$ is even for every integer $x$, this is equivalent to $$3|28x-14$$ and therefore $$28x\equiv 14\mod 3$$

Reducing $28$ and $14$ mod $3$ gives $$x\equiv 2\mod 3$$

Hence the positive solutions are $2,5,8,\cdots$

  • $\begingroup$ Why doesn't the given formula $\begin{equation*} x_0 = \frac{bp}{\text{gcd}(a, m)} \; ( \text{mod} \; m). \end{equation*}$ give the $x_0$ as 2 ? $\endgroup$ – Goun2 Aug 22 '17 at 23:01
  • $\begingroup$ What does "p" mean in this formula ? $\endgroup$ – Peter Aug 22 '17 at 23:08
  • 1
    $\begingroup$ $\begin{equation*} ap + mq = \text{gcd}(a, m). \end{equation*}$ $\endgroup$ – Goun2 Aug 22 '17 at 23:11
  • $\begingroup$ a-calculator.com/congruence/#faq-formula $\endgroup$ – Goun2 Aug 22 '17 at 23:12
  • $\begingroup$ @hjx so bezout's identity. $\endgroup$ – user451844 Aug 23 '17 at 0:27

There in no discrepancy: $ $ your solution is $\,x\equiv\, 5,\,5\!+\!3\,\equiv\, 5,\,2\pmod{\!6},\,$ same as claimed.

Remark $ $ Generally, as above, we will need to reduce the results of the formula $\bmod m\,$ if we wish to obtain the least nonnegative representatives of the solutions.

  • $\begingroup$ Bill, in the tutorial the writter says, Now, unless gcd(a,m) evenly divides b there won't be any solutions to the linear congruence. Though if it does, our first solution is given by.. Could you explain what did He meant by saing that ? $\endgroup$ – Goun2 Aug 23 '17 at 1:37
  • $\begingroup$ in the formula, what is this (mod m) taking mod of ? $\begin{equation*} x_n = x_0 + \frac{nm}{\text{gcd}(a, m)} \; ( \text{mod} \; m) \end{equation*}$ I solved the following congruence $131x\equiv 21 \ (mod \ 77)$ and I got $ 56 + \frac{77n}{1}$ mod $77$, $77$ mod $77$ would be 0. $\endgroup$ – Goun2 Aug 23 '17 at 2:01
  • 1
    $\begingroup$ @hjx If $\,ax\equiv b\pmod{\!m}\,$ is solvable then $\,b = \color{#c00}ax-\color{#c00}mn\,$ so $\,d\mid \color{#c00}{a,m}\,\Rightarrow\,d\mid b.\,$ Thus choosing $\,d = \gcd(a,m)\,$ we can cancel $\,d\,$ from $\,a,b,m\,$ so reducing to the simpler case where $\,a,m\,$ are coprime, so $\,a^{-1}\!\pmod{\!m}\,$ exists, so $\,x\equiv a^{-1}b\pmod{\!m}.\\ $ $\endgroup$ – Bill Dubuque Aug 23 '17 at 2:03
  • 1
    $\begingroup$ @hjx It's not "taking mod". Rather $\,x\equiv y\pmod{\!m}\iff m\mid x-y\iff x,y$ leave the same remainder when divided by $m,\,$ i.e. $\ x\bmod m\, =\, y\bmod m.\,$ For more on "mod" as a binary operator (remainder) vs. ternary congruence relation see this answer and this one. $\endgroup$ – Bill Dubuque Aug 23 '17 at 2:13
  • 1
    $\begingroup$ @hjjx It should be $\,x_0\equiv\,\ldots $ not $\,x_0 =\,\ldots $ since the latter is not even defined. But there is much abuse of notation when it comes to congruences (and much misunderstanding). $\endgroup$ – Bill Dubuque Aug 23 '17 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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