2
$\begingroup$

Following is the equation:

enter image description here

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.

$\endgroup$
  • 1
    $\begingroup$ Have you tried searching the documentation centre ? $\endgroup$ – Sektor Feb 15 '14 at 18:51
  • $\begingroup$ Assuming a and b are integers then the solutions are (a+1,b+1) or (a-1,b-1) for any a,b. This can be seen by rearranging (x-a)(y-b)=1. The factors must either both be 1 or both be -1. Noting when a=b=1 only (2,2) applies and similarly a=b= -1 the (-2,-2). Mathematica is not required. $\endgroup$ – ubpdqn Feb 16 '14 at 10:32
3
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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$.

$\endgroup$
0
$\begingroup$

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]

Mathematica graphics

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}

$\endgroup$

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.