0

I am interested in understand how to solve for $x$ equations of the type:

$a \equiv b \pmod {c.x + d}$ where $a, b, c$, and $d$ are integer constants.

I can arrive sometimes at a solution through simply incrementing $x$ by $1$ until the equation is satisfied but this does not seem very efficient

i) Is it possible rearrange the equation to isolate $x$?

ii) Can we tell if there is no, one or multiple integer solutions?

iii) In the case of no solutions, is there a fast algorithm to determine that there are no solutions?

Robert
  • 53

2 Answers2

1

This equation can be rewritten as $$cx + d \mid a-b.$$ Now let $g := gcd(c,d)$. Surely, $g$ divides all terms of the form $cx + d$, hence if $g$ does not divide $a-b$, you will have no solutions. We can hence assume that $g$ divides $a-b$ and thus divide everything by $g$.

So from now on assume w.l.o.g. that $gcd(c,d) = 1$. Furthermore, we set $e := a-b$ for simplicity. Now let $r$ be any divisor of $e$. Then we want to know if the equation $$cx + d = r$$ has a solution in the integers (of course it has exactly one solution, the only question is if the solution will be an integer). Thus, we need to check if $$\frac{r - d}{c}$$ is an integer. This is equivalent to $$r \equiv d \mod{c}.$$

Depending on $c$ and $e$, there is much or not so much to check here and there are still some tricks you can use to not have to check all $r$, but I'm sure you can figure that out. :)

Dirk
  • 6,359
  • Thank you Dirk - please see my comments below which apply to your and shuri2060's findings. – Robert Jul 14 '17 at 10:08
1

Some general advice for when you're stuck on questions involving modular arithmetic is to see if falling back to the definition helps out.

$$a\equiv b\pmod{cx+d}\iff (\exists k\in\mathbb Z)\,\,\,(a=b+k(cx+d) \land cx+d\in\mathbb Z^+)\,\,\,,\,\,\,a,b,c,d\in\mathbb Z$$

Then for $a,b,c,d,k\in\mathbb Z$,

$$a=b+k(cx+d) \land cx+d\in\mathbb Z^+\implies$$

If $c=0$, then $x\in\mathbb C$.

Also, $c=0\land x\in\mathbb C\implies a\equiv b\pmod{cx+d}$.

If $c\neq 0\land a=b$, then $k=0\lor cx+d=0$

$$\implies cx+d\in\mathbb N_0\implies x=\frac{n-d}{c}\,\,\,,\,\,\,n\in\mathbb N_0$$

Also, $c\neq0\land a=b\land x=\frac{n-d}{c}\,\,\,,\,\,\,n\in\mathbb N_0\implies a\equiv b\pmod{cx+d}$.

If $c\neq 0\land a\neq b$, then $k\neq0$

$$\implies x=\frac{a-b-dk}{ck}$$

Also, $c\neq0\land a\neq b\land x=\frac{a-b-dk}{ck}\,\,\,,\,\,\,k\in\mathbb Z^*\implies a\equiv b\pmod{cx+d}$

Therefore

$$(\forall a,b,c,d\in\mathbb Z)\,\,\,a\equiv b\pmod{cx+d} \iff (c=0\land x\in\mathbb C)\lor\left(c\neq0\land\left(\left(a=b\land x=\frac{k-d}{c}\,\,\,,\,\,\,k\in\mathbb N_0\right)\lor\left(a\neq b\land x=\frac{a-b-dk}{ck}\,\,\,,\,\,\,k\in\mathbb Z^*\right)\right)\right)$$

Shuri2060
  • 4,353
  • Thank you for your responses. I'm going to enjoy reading them - I really appreciate the effort Dirk and Shuri have made. – Robert Jul 12 '17 at 16:01
  • I don't think there needs to be any condition on $cx+d\in\mathbb Z^+$. – Simply Beautiful Art Jul 12 '17 at 16:59
  • Not sure if the statement is defined for $cx+d=0$. Also, if $cx+d=1$, then $a,b$ can be any numbers in $\mathbb Z^+$. – Simply Beautiful Art Jul 12 '17 at 17:01
  • @SimplyBeautifulArt On the sources I could find, they generally mentioned $n\in\mathbb Z^+$ for $\mod n$. Also, isn't $-1\equiv 1\pmod 1$ true? – Shuri2060 Jul 12 '17 at 17:10
  • One can naturally extend it to any $n\in\mathbb R$. And yes, $-1\equiv1\pmod1$ – Simply Beautiful Art Jul 12 '17 at 17:12
  • I agree, but the general definition used is $n\in\mathbb Z^+$? I guess the solution depends on which definition the question uses – Shuri2060 Jul 12 '17 at 17:16
  • This is very interesting. Both Dirk Liebhold, through "r", and Shuri2060, through "k", have introduced a factor of (a-b). These factors are hard to compute for the equation examples I am looking at. In fact my initial equations with 4 constants were constructed to help find those factors. Can I conclude that a simple algorithm to determine whether x has an integer solution does not exist, given that solutions to x depend upon a complex operation, factorization, on one of the constants? – Robert Jul 13 '17 at 11:06
  • An example I was working with - "a" is a large biprime, and the assumption is that it is not possible to factorise easily. Assume one of the factors of the biprime is of the form "c.x +d", and therefore "b"=0. (I have my reasons for this construction). Because I do not know what the factors of the biprime are, but I do know "a", then, if I can easily show that a==0mod(c.x+d) has no integer solution for "x" then I can ignore dmodc as a representation of one of the factors of the biprime. My previous comment concluded that this simple algorithm to find the integer soln for "x" does not exist. – Robert Jul 13 '17 at 11:18
  • @Robert I don't think I can help much on this problem, but I'd probably agree, although even though $x$ is in this form, such an algorithm may still exist, even if hard to find – Shuri2060 Jul 13 '17 at 14:24