Following is the equation:
Need to solve for integer values of x,y when a,b lies between -1000 and 1000. Problem is to find the number of integer values of pair (x,y) that satisfy it.
Following is the equation:
Need to solve for integer values of x,y when a,b lies between -1000 and 1000. Problem is to find the number of integer values of pair (x,y) that satisfy it.
Reduce works in general. First, multiply both sides of the equation by x y
to simplify, and then:
Reduce[a b - b x - a y + x y == 1, {x, y, a, b}, Integers]
((C[1] | C[2]) ∈ Integers && x == C[1] && y == C[2] &&
a == -1 + C[1] && b == -1 + C[2]) ||
((C[1] | C[2]) ∈ Integers && x == C[1] && y == C[2] &&
a == 1 + C[1] && b == 1 + C[2])
This answer says, in words, to pick any two integers C[1] and C[2], set them equal to x
and y
. Corresponding values for a
and b
are then a=-1+x
and b=-1+y
. A second solution is given by a=1+x
and b=1+y
.
Accordingly, there are as many integer answers to this problem as there are integer pairs in the range you wish to consider.
Problem is to find the number of integer values of pair (x,y) that satisfy it
Here is a way to proceed:
We'll use Tuples
to generate the pairs (a, b)
of Integers
in the range we're interested. I'm just going to do this for the range [-2, 2]
Tuples[Range[-2, 2], 2]
{{-2, -2}, {-2, -1}, {-2, 0}, {-2, 1}, {-2,
2}, {-1, -2}, {-1, -1}, {-1, 0}, {-1, 1}, {-1,
2}, {0, -2}, {0, -1}, {0, 0}, {0, 1}, {0, 2}, {1, -2}, {1, -1}, {1,
0}, {1, 1}, {1, 2}, {2, -2}, {2, -1}, {2, 0}, {2, 1}, {2, 2}}
Now we use FindInstance
with the 4th argument (This tells Mathematica how many solutions you want found). Below I've requested a maximum of 3
sol = FindInstance[(#1/x - 1) (#2/y - 1) == 1/(x y), {x, y}, Integers, 3] &
@@@ Tuples[Range[-2, 2], 2]
You can then use Length
to find how many solutions were found for each pair:
Length /@ sol
{2, 1, 2, 1, 2, 1, 1, 1, 0, 1, 2, 1, 2, 1, 2, 1, 0, 1, 1, 1, 2, 1, 2, 1, 2}
For each pair (a,b) you can use Reduce,
a=1;b=10;
Reduce[(a/x - 1) (b/y - 1) == 1/(x y) , {x, y}, Integers]
Then, use ToRules
to convert to proper solutions.
However, this is probably quite inefficient and may take some time for all combinations of $a,b$.