Linear Diophantine equation in two variables with additional constraints

922 Views Asked by At

Given,

$$aX + bY = c$$

where,

$$c > b > a > 0;\quad X, Y > 0;\quad b\nmid c, a\nmid c$$

I want to find out if a solution exists as efficiently as possible (I'm not interested in the solutions). Are there any calculations I can make before (or without the need for) finding $\operatorname{gcd}(a, b)$ that can possibly save some time (even if for only few special cases)? $c, b, a$ can be very large numbers.

"Probably not" still counts as answer for me. You don't have to be 100% certain. I just want to make sure I'm not missing something that's very obvious.

P.S., English is not my first language.

2

There are 2 best solutions below

1
On BEST ANSWER

If gcd(a,b) divides c, then there are infinitely many solutions for the equation

aX + bY = c

Divide the equation by gcd(a,b) to get the reduced equation

sX + tY = u

where gcd(s,t)=1

With the extended algorithm for the gcd-calculation, you can calculate a solution (m,n).

All solutions are given by

X = kt + m

Y = -ks + n

for some integer k.

If there is an integer k, such that X and Y satisfy all conditions, a solution is found. In order to check this, you have to find bounds for the number k by solving the desired inequalities and check, if the intervals found have a non-empty intersection.

So, this is the way to find solutions.

Now, I come to your additional restrictions. Since 3x + 4y = 5 is an equation not having integer solutions with x>0 and y>0, it is not enough to check, whether gcd(a,b) divides c, even if the additional restrictions hold.

But the way I described is very efficient even for very large numbers, since it only requires modulo-calculations.

I doubt that there are faster ways to decide if there are solutions of the desired form.

1
On

I would say probably not. Finding $\gcd(a,b)$ is computationally fast (with technology). If you get $\gcd(a,b)\nmid c$, then there are no solutions. See this for more general theory and examples.