Diophantine Approximation: find lowest possible denominator to approximate within given precision Challenge
Given a number x and a precision e, find the lowest positive integer q such that x can be approximated as a fraction p / q within precision e.
In other words, find the lowest positive integer q such that there exists an integer p such that abs(x - p/q) &lt; e.
Input

The pair (x, e) where x is a floating-point number, and e is a positive floating-point number.
Alternatively, a pair (x, n) where n is a nonnegative integer; then e is implicitly defined as 10**(-n) or 2**(-n), meaning n is the precision in number of digits/bits.

Restricting x to positive floating-point is acceptable.
Output
The denominator q, which is a positive integer.
Test cases

Whenever e &gt; 0.5 ------------------------&gt; 1 because x ≈ an integer
Whenever x is an integer ----------------&gt; 1 because x ≈ itself
(3.141592653589793, 0.2) ------------&gt; 1 because x ≈ 3
(3.141592653589793, 0.0015) --------&gt; 7 because x ≈ 22/7
(3.141592653589793, 0.0000003) ---&gt; 113 because x ≈ 355/113
(0.41, 0.01) -------------------------------&gt; 12 for 5/12 or 5 for 2/5, see Rules below

Rules

This is code-golf, the shortest code wins!
Although the input is &quot;a pair&quot;, how to encode a pair is unspecified
The type used for x must allow a reasonable precision
Floating-point precision errors can be ignored as long as the algorithm is correct. For instance, the output for (0.41, 0.01) should be 12 for 5/12, but the output 5 is acceptable because 0.41-2/5 gives 0.009999999999999953

Related challenges

Find the simplest value between two values
Closest fraction
R, Xx bytes
Note: this challenge is quite a good introductory-challenge for R, which is the 'language-of-the-month' for September 2020, so I've blanked-out my answer in the hope of encouraging some other golfers to have a shot at it in R, too...


 50 bytes


    function(x,e,s=1:e^-1)s[(x-round(x*s)/s)^2&lt;e^2][1]

Try it online!
Function with arguments x &amp; error e.  Can handle negative x (even though not required for challenge)

Note 2: dammit!  a port of xnor's approach is 6 bytes shorter still:


 44 bytes


    function(x,e,s=1:e^-1)s[(x+e)%%(1/s)&lt;2*e][1]

Try it online!