0

This equation is like this: $$x^2-x+6 \equiv 0 \pmod{9}$$

I want to find x by using modular arithmetic. How I could do that?

My solution was:

$$\begin{align*} x(x-1) &\equiv -6 \pmod{9}\\ x(x-1) &\equiv 3 \pmod{9} \end{align*}$$

So $x$ is either: $$ x \equiv 3\pmod{9}$$

or

$$x - 1 \equiv 3 \pmod{9}$$

Which is $x \equiv 4 \pmod{9}$

I know what I have done is very dumb. So what is the correct solution? Give me the instructions also please.

Aiden Chow
  • 2,849
  • 10
  • 32
  • 1
    $3^2-3+6=12,$ not $0$ mod $9.$ – coffeemath Feb 13 '20 at 22:04
  • @coffeemath That's Modular Arithmetic. It just works like that. – TechnoKnight Feb 13 '20 at 22:06
  • You can first solve $x^2-x+6=0\pmod{3}$. Note that this is the same as $(x+1)^2=1\pmod{3}$. So, you get $x+1=1,2$. Since $3$ is prime, there are no more solutions for this congruence. Now, the derivative of $f(x)=x^2-x+6$ is $2x-1$, which evaluated at $x=0$ and $x=1$ is different from $0$ modulo $3$. Therefore, we can find solutions of the original congruence of the form $x=3K+x_0$, with $x_0=0,1$. The fact that $f'(x_0)\neq0$ gives you a linear congruence for $K$ that has unique solution in each case. –  Feb 13 '20 at 22:08
  • The above is the process that you can follow for general polynomial congruences with modulo a power of a prime. The business with the derivative is Hensel's lemma. When the modulo is not a power of a prime, you reduce to study the congruences of the powers of primes that divide the modulo combined with the Chinese remainder theorem. –  Feb 13 '20 at 22:10
  • $3\equiv 2*6\pmod 9$. So you can't assume $3$ is "prime". – fleablood Feb 13 '20 at 22:15
  • 4
    This is a typical error I see. In the reals (and complex numbers), if a product is equal to $0$ then one of the factors is equal to $0$. So from $x(x-1)=0$, you can deduce $x=0$ or $x-1=0$. But somehow, people take it as license to do so when the product is not equal to $0$, saying something like "if $x(x-1)=3$, then either $x=3$ or $x-1=3$". That's just not true. In the real numbers you can do it when the product equals $0$, but not when it equals something else. It's worse here, because in the setting of "modulo 9", you can't even do it when the product is equal to $0$. – Arturo Magidin Feb 13 '20 at 22:53
  • 1
    Two things two watch out for. $3\pmod n$ need not be "prime". Indeed $26\equiv 3\pmod 9$ as is $34\equiv 3 \pmod 9$. And if $n$ is not prime then $\pmod n$ will have "zero divisors". It will be possible of for $ab\equiv 0\pmod n$ without either $a\equiv 0$ or $b\equiv 0$. – fleablood Feb 13 '20 at 23:45
  • 1
    I added an answer showing the general successive approximation method (Hensel's Lemma), as mentioned above by @tora, but without requiring any prior knowledge of such. This is a very powerful technique that generalizes widely so it is well worth the effort to learn. – Bill Dubuque Feb 14 '20 at 00:12
  • You've had seven answers, Techno. If you found one of them particularly helpful, let me encourage you to "accept" it by clicking in the check mark next to it. – Gerry Myerson Feb 15 '20 at 11:32
  • Today would be a good day to do that, Techno. And if you aren't satisfied with any of the answers, perhaps you could leave a comment to tell us what more you need. – Gerry Myerson Feb 16 '20 at 21:56
  • Techno, it's not polite to ask a question and then refuse to engage with the people who have tried to help you by posting answers. – Gerry Myerson Feb 17 '20 at 22:22

8 Answers8

5

Let me address what you did, rather than how to do it correctly, as others have answered with sundry ways of finding the answer correctly.

The very wrong thing you did was go from $$x(x-1)\equiv 3\pmod{9}$$ to $$x\equiv 3 \pmod{9}\quad\text{or}\quad x-1\equiv 3\pmod{9}.$$

That's an error that I often see in basic algebra, and it is compounded here.

In usual algebra, working in the integers, rationals, reals, or complex numbers, we have a very important property:

$$\text{if }ab=0,\text{ then }a=0\text{ or }b=0.$$

So if you were working in the real numbers, from something like $x(x-1)=0$ you would be able to conclude that either $x=0$ or $x-1=0$.

However, this is not true when the product does not equal $0$. For example, from $xy=6$ we cannot conclude that $x=6$ or $y=6$! Yet students who have seen the "trick" for solving quadratics by factoring try to extend this argument to that situation. For example, they know that they can solve $x^2-5x+6=0$ by saying:

$$\begin{align*} x^2-5x+6&=0\\ (x-3)(x-2) &= 0 \end{align*}$$ therefore either $x-3=0$ or $x-2=0$, so $x=3$ or $x=2$.

This is correct. It's correct because the only way a product in $\mathbb{R}$ can equal $0$ is if at least one factor is equal to $0$.

But then students think they can do something like the following:

$$\begin{align*} x^2-5x-6 &=0\\ x^2-5x &= 6\\ x(x-5)&=6 \end{align*}$$ and therefore $x=6$ or $x-5=6$; so $x=6$ or $x=11$.

That's wrong. You can't do that because whereas the only way to get $0$ when you multiply two reals is if one of them is $0$; getting a $6$ as the result of a product does not mean that one of the factors has to be $6$.

Now, your argument would have been wrong in the reals; the further problem here is that it would have been wrong modulo $9$ even if you had obtained the congruence $x(x-1)\equiv 0\pmod{9}$. The reason is that when you are working modulo $9$, it is possible for a product to be $0$, yet neither factor to be $0$: indeed, $(3)(3)\equiv 0\pmod{9}$, for example. So when you are working modulo $9$, you can't even use this type of argument when the product equals $0$, let alone when it doesn't equal $0$.

So you are taking an incorrect argument from another setting, already a problem, and compounding that problem by trying to use it in a setting where even the correct argument would not have worked.

J. W. Tanner
  • 60,406
Arturo Magidin
  • 398,050
2

Complete the square, noting $4^{-1}\equiv7$ and $2^{-1}\equiv5\pmod9$:

$x^2-x+4^{-1}\equiv x^2-x+7\equiv1\pmod9$ $\iff$

$(x-2^{-1})^2\equiv1\pmod9$ $\iff$

$x\equiv2^{-1}\pm1\equiv4 $ or $6\pmod9$,

because $9|y^2-1=(y+1)(y-1)$ means $9|y+1$ or $9|y-1$,

since $3|y+1$ and $3|y-1$ means $3|(y+1)-(y-1)=2,$

which is clearly not so.

J. W. Tanner
  • 60,406
  • Wait. From where 1 / 4 appeared? And why plus-or-minus is there? I think your solution is the correct one because it is the same as the exercise' solution have. But I don't understand how quite you did it. – TechnoKnight Feb 13 '20 at 22:13
  • $1/4$ appeared when completing the square: $x^2-x+c=(x-d)^2=x^2-2d+d^2\implies2d=1\implies d=1/2\implies c=d^2=1/4$; $\pm$ comes because if $y^2\equiv1\pmod9$ then $y\equiv\pm1\pmod9$ – J. W. Tanner Feb 13 '20 at 22:21
  • @TechnoKnight Beware that the argument in the above answer is either incomplete or incorrect, viz. in the final implicit equivalence it is not true in general that $\bmod n!:\ y^2\equiv 1 \iff y\equiv 1.,$ To obtain a complete correct proof one needs to prove why it is true when $,n = 9.,$ Also when composing such proofs it is essential to explicitly state the intended inferences between the listed congruences, using either arrows or equivalent natural language. Failure to do so will quickly lead one astray in more complex contexts. – Bill Dubuque Feb 14 '20 at 16:56
  • @BillDubuque: I edited my answer in response to your comment – J. W. Tanner Feb 14 '20 at 17:00
  • @J.W.T That's better, but if you use only unidrectional arrrows $(\Rightarrow)$ then you need to actually verify that the derived roots work (i.e. are not extraneous). This problem is avoided if you use bidirectional arrows - then the chain of backward arrows $(\Leftarrow)$ implies that the "possible" roots are "actual" roots. – Bill Dubuque Feb 14 '20 at 17:26
  • This is not nitpicking since it is a very common pitfall for novices to apply a noninvertible inference (e.g. scaling by a zero-divisor, which introduces extraneous solutions). This can't happen over fields (which is why one can better get away with omitting the arrows in that case, though even there it is possible to slip up by multiplying by something that is zero but not obviously zero, as in various fake proofs that $0 = 1$ etc. – Bill Dubuque Feb 14 '20 at 17:26
  • @BillDubuque: of course, you are correct that -- the way I had the arrows before -- I left it up to OP to verify the derived solutions, but now I made the arrows bidirectional – J. W. Tanner Feb 14 '20 at 20:35
  • Re: modular quadratic formula: see here for much more. – Bill Dubuque Feb 27 '24 at 01:45
1

$x^2-x+6\equiv0\bmod9$,

$4x^2-4x+24\equiv0\bmod9$,

$4x^2-4x+1\equiv-23\equiv4\bmod9$,

$(2x-1)^2\equiv4\bmod9$.

Can you take it from there?

Gerry Myerson
  • 179,216
  • Wait. How did you multiply by 4 without multiplying 9 too? – TechnoKnight Feb 13 '20 at 22:06
  • @TechnoKnight $4$ is relatively prime to $9$. The property that you are remembering is for arbitrary numbers, but if you know that $4$ is relatively prime to $9$, then $4(x^2-x+6)$ is multiple of $9$ if and only if $x^2-x+6$ is multiple of $9$. –  Feb 13 '20 at 22:13
  • I just did. Why shouldn't I? Do you understand what $a\equiv b\bmod c$ means? It means $b-a$ is a multiple of $c$. If $b-a$ is a multiple of $c$, then $4(b-a)$ is also a multiple of $c$, isn't it? – Gerry Myerson Feb 13 '20 at 22:13
  • 2
    better question is Why did you multiply by $4$? How did you know that would help? – J. W. Tanner Feb 13 '20 at 22:27
  • 1
    @tora: $\gcd(4,9)=1$ is irrelevant. It becomes important if you want to cancel, not if you want to multiply. – Arturo Magidin Feb 13 '20 at 23:19
  • 1
    @ArturoMagidin Which is exactly what you need to get the implication that solutions of the new equation are solutions of the original. So, shh. –  Feb 14 '20 at 00:09
  • @J.W.Tanner That is how you complete any square. That's why. –  Feb 14 '20 at 00:15
  • @J.W Going for a square, I could have done $x^2-x+(1/4)\equiv-23/4\bmod9$ but OP might have gotten confused by those denominators. To avoid that, I took the precaution of first multiplying by four. – Gerry Myerson Feb 14 '20 at 00:18
  • 1
    I see; thank you – J. W. Tanner Feb 14 '20 at 00:19
  • @tora I think J.W. knows how to complete the square. – Gerry Myerson Feb 14 '20 at 00:19
  • @GerryMyerson The question is not knowing, but how well they know it and they clearly didn't know it well enough. –  Feb 14 '20 at 00:20
  • @tora, J.W. has answered over 1300 questions on this website. I'm confident J.W. knows completing the square at least as well as you do. – Gerry Myerson Feb 14 '20 at 00:36
  • 1
    The number of questions and reputation on this website means nothing I could name more than ten people with more than 100K reputation and more answers than that that are vastly incompetent doing mathematics. –  Feb 14 '20 at 00:46
  • @tora have a look at some of J.W.'s answers in abstract algebra, and then tell me whether you think J.W. is incompetent in high school algebra. – Gerry Myerson Feb 14 '20 at 00:49
  • @TechnoKnight Part of the confusion in the comments above is caused by imprecision in the answer. It doesn't say how the listed congruences are intended to be related. Does it intend to have $\Rightarrow$ or $\iff$ between all of them? The difference can be crucial (e.g. if you use only $\Rightarrow$ then you may get extraneous solutions, so you need to verify them). In order to convince the reader that a proof is complete and correct it is essential to explicitly notate the intended inferences. – Bill Dubuque Feb 14 '20 at 02:24
  • @Bill I hope my edit has clarified the intention. – Gerry Myerson Feb 14 '20 at 02:42
  • @Gerry Does comma denote some sort of logical implication on your planet? – Bill Dubuque Feb 14 '20 at 03:55
  • Yes, @Bill, it does. – Gerry Myerson Feb 14 '20 at 04:33
  • @Gerry Please do explain, since I've never heard of such. – Bill Dubuque Feb 14 '20 at 05:06
  • What's to explain, @Bill? It's a sequence of steps. You do the first step, then the second step, then the third step, then the fourth. Along the way, OP is meant to stop and think about what's being done. I believe in leaving some work for OP to do. If OP can't follow the logic, OP is free to ask questions (which actually happened). You, too, can ask questions if you don't understand what I've done. – Gerry Myerson Feb 14 '20 at 08:29
1

It'll help to factorize $x^2-x+6$ modulo $9$, using the fact that $x^2-x+6-9n$ has discriminant $36n-23$. This is $7^2$ when $n=2$. Since $9|(x-4)(x+3)=(x^2-x+6)-2\times9$, the two factors not differing by a multiple of the prime number $3=\sqrt{9}$, the solutions are $9|x-4,\,9|x+3$ (or, if you prefer, you can write the latter as $9|x-6$).

J.G.
  • 115,835
  • @OP The "not differing" means this: by unique prime factorization (or Euclid's Lemma) we deduce that $,9\mid (x!-!4)(x!+!3)\iff 9\mid x!-!4\ $ or $\ 9\mid x!+!3\ $ or $\ 3\mid x!-!4,, 3\mid x!+!3.,$ The last case cannot occur, else $\bmod 3!:\ 4\equiv x\equiv -3.,$ But it can occur generally, e.g. consider this nonunique factorization $!\bmod 8!:\ (x-1)(x+1)\equiv (x-3)(x+3)\ \ \ $ – Bill Dubuque Feb 14 '20 at 00:51
1

If $x\equiv2\pmod3$, there are no solutions because $(3k+2)^2-3k-2=9k^2+3k+2\not\equiv0\pmod3$.

If $x\equiv0\pmod3$, then $x^2\equiv0\pmod9$, so the solutions are given by $-x+6\equiv\pmod9$, i.e. $x=9k+6$.

If $x\equiv1\pmod3$, then $x^2-x+6=9k^2+6k+1-3k-1+6\equiv3k+6\pmod9$, so $k+2\equiv0\pmod3$, and the solutions are $k=3j+1$, or $x=9j+4$.

So the solutions are $4,6\pmod9$.

JMP
  • 21,771
1

A general method: lift easy roots $\!\bmod 3\,$ to $\!\bmod 3^2$ (by Hensel's Lemma = Newton's method)

$\!\bmod 3\!:\ 0\equiv f(x) = x^2\!-\!x\!+\!6\equiv x(x\!-\!1)\!$ $\iff\! x\equiv\color{#c00}{0,1 =: r},\ $ so $\ x = \color{#c00}r\color{#0a0}{ + 3j}$

$\!\bmod 9\!:\ 0\equiv {f(\color{#c00}r\!\color{#0a0}{+\!3j})}\overset{{\color{#90f}{\rm TT}_{\phantom |}\!}}\equiv\, \overbrace{f(\color{#c00}r)}^{\large 6}+\smash{\overbrace{(2r\!-\!1)}^{ f'(r)}}\,\color{#0a0}{3j}\iff\! (2r\!-\!1)3j\equiv 3$
$\overset{\large \div\ 3}\iff\! \bmod 3\!:\ j\equiv \dfrac{1}{2r\!-\!1}\ $ so $\,\ \bbox[5px,border:1px solid #c00]{ \begin{align} &\color{#c00}{r \equiv 0}\Rightarrow\, j \equiv -1\Rightarrow\, x\equiv r\!+\!3j \equiv -3\!\!\!\pmod{\!9}^{}\!\! \!\!\\[.1em] &\color{#c00}{r \equiv 1}\Rightarrow\, j\ \:\!\equiv\:\!\ 1\, \Rightarrow\, x\equiv r\!+\!3j \ \equiv\:\!\ 4\!\!\pmod{\!9}\end{align}}^{\phantom{|^|}}\!\!$

We used $\,\color{#90f}{\rm TT_{\phantom |}\!}\!\!:\ \color{0af}{f(r\!+\!x)} \equiv f(r) + f'(r)\, x\, \pmod{\!x^2},\,$ for $\, x = 3j,\,$ i.e. we employed $\rm\color{#90f}{Taylor's\ Theorem}$ for a polynomial $\,f(x)\,$ [or, w/o TT, simply expand $\,f(r\!+\!x)$].

Bill Dubuque
  • 272,048
0

$9$ is odd, so every value is divisible by $2 \mod 9$ but adding (or subtracting) $9$ if it is odd.

So completing the square is always attemptable.

But not every number will have square roots and not all quadratics will be solvable. If $n= 3k \pm i$ where $i=1$ or $0$ then $n^2=(9k^2 \pm 6ki +i^2)\equiv \mp 3ki + i^2$ so the squares in $\pmod 9$ will be if $i=0$ then $0 \equiv 0^2, 3^2, 6^2$; other wise $i\equiv 1$ and if $k=0$ then $1\equiv 1^2, 8^2$ and if $k=1$ then $4\equiv 2^2,7^2$ and if $k=2$ then $7\equiv 4^2, 5^2$.

Completing the square:

$x^2 -x + 6 \equiv 0 \pmod 9$

$x^2 +8x + 6\equiv 0\pmod 9$

$x^2+ 8x + 16-10\equiv 0\pmod 9$

$(x+4)^2 \equiv 10\equiv 1\pmod 9$

So $x+4 \equiv 1,8\pmod 9$

$x\equiv 6,4\pmod 9$.

However $x^2 -x + 4\equiv 0\pmod 9$ would have no solutions as

$x^2 -x +4\equiv 0\pmod 9\implies$

$x^2 + 8x+ 16 -12\equiv 0\pmod 9\implies$

$(x+4)^2 \equiv 3\pmod 9$ and there is no $a^2 \equiv 3\pmod 9$ solutions.

fleablood
  • 124,253
0

Update: I just noticed that this answer is in the same vein as the answer given by JMP, but the step-by-step instructions(method) follows a predetermined pedagogical flow.


Solve

$\tag 1 x^2 - x + 6 \equiv 0 \pmod9$

Let $T = \{0,1,2\}$ and recall that every integer $n$ satisfying $0 \le n \lt 9$ has a representation

$\tag 2 n = 3q + r \quad \text{where } r,q \in T$

Using simple algebra,

$\tag 3 n^2 -n + 6 = 9 q^2 + 6 q r - 3 q + r^2 - r + 6$

Setting $r = 0$ on the rhs of $\text{(3)}$,

$\quad 9 q^2 - 3 q + 6 \equiv 0 \pmod9 \; \text{ implies } \; 3q \equiv 6 \pmod9$

and we see that $[x] = [3\cdot2 + 0] = [6]$ is a solution to $\text{(1)}$

Setting $r = 1 $on the rhs of $\text{(3)}$,

$\quad 9q^2 + 3q + 6 \equiv 0 \pmod9 \; \text{ implies } \; 3q + 6 \equiv 0 \pmod9$

and we see that $[x] = [3\cdot1 + 1] = [4]$ is a solution to $\text{(1)}$

Setting $r = 2$ on the rhs of $\text{(3)}$,

$\quad 9 q^2 + 9 q + 8 \equiv 0 \pmod9 \; \text{ implies } \; 8 \equiv 0 \pmod9$

We conclude that $[4]$ and $[6]$ are all the solutions to $\text{(1)}$.

CopyPasteIt
  • 11,366
  • This is exactly the same as Hensel / Newton method shown in my answer (except you compute $f(r+3q)$ directly (vs. by Taylor's formula). – Bill Dubuque Feb 27 '24 at 01:40