Finding whole number solutions to a double inequality

363 Views Asked by At

I'm looking for a fast method to find an $(x, y)$ integer solution to a double inequality.

Given an A between $0$ and $1$:

$$ {y \over x^2} < A < {y \over x^2 - 1} $$


For example, given A = 0.017 the first solution I can find is (106, 191) and only by brute force... trying from $$x = [2, +\infty] \\ y = [1, x]$$


Any ideas would be greatly appreciated.

Also, apologies for any poor maths terminologies I have used.

1

There are 1 best solutions below

0
On

Since the question leaves several questions unresolved, such as 1) what does fast mean (except not brute force), 2) what are values of A, 3) how accurate are values of A (to three decimal places?), and 4) if you are doing this manually or writing a program, this answer may, at best, help (but isn't necessarily a solution).

To use the example, you want values of $17x^2\;mod\;1000$ that are small. In the case of $106$ the value of that expression is $12$. For all values of $8 \leq x < 106$ the value is at least $33$.

When you find a value of $x$ where the value of the expression is small, you can then see if it satisfies the inequalities ($y$ will be $floor(Ax^2)$). So you are still brute forcing $x$, but you are skipping the calculation of $y$ and the inequalities for most cases.

To further optimize you could skip a few values at time. For example, say that you are iterating through $x$ and it is currently $40$. The remainder will be $200$ (in the example). The remainder for the difference $41$ and $42$ will be $((41+42)*17\;mod\;1000) = 377$. The remainder for the difference between $42$ and $43$ will be $377+2*17=411$. Since $200+377+411 < 1000$ you could skip checking $x=41,42$. In other words you could skip from $40$ to $43$.