2
$\begingroup$

Suppose that we are given an irrational number $z$, a value $x\in[0,1)$ and soe $\epsilon> 0$. We want to find an integer $n$ such that $\{nz\}\in (x,x+\epsilon)$ . (Note that by $\{\alpha\}$ I mean the fractional part of $\alpha$ in this context).

Such an $n$ clearly must exist as $\{nz\}$ is dense in $[0,1]$. But I have not been able to find a good method to come up with an $n$. I thought about putting $z$ as a periodic fraction but I am not sure how to proceed.

Some code in c or a similar language would be greatly appreciated.

  • 0
    I must still be misunderstanding your question: why can't you take $n = 1$ and $x$ to be the fractional part of $z$?2017-01-25
  • 0
    Sorry, it was unclear, you are given $z,x$ and $\epsilon$ and need to find $n$.2017-01-25
  • 0
    right, thanks. ${}$2017-01-26

2 Answers 2

1

By Dirichlet's approximation theorem for $\forall z \in \mathbb{R}$ and $\forall N \in \mathbb{N}$ there exist integers $p,q \in \mathbb{Z}$ such that $|q z - p| \lt \frac{1}{N}$. Integers $p,q$ can be derived from the convergents of the continued fraction of $z$.

It can be assumed WLOG that $0 \le q z - p \lt \frac{1}{N}\,$ (otherwise replace $q \mapsto -q\,$, $p \mapsto -p\,$), with the first inequality being strict when $z$ is irrational. Taking $N \gt \cfrac{1}{\epsilon}\,$ this gives $0 \lt \{qz\} = qz - p \lt \epsilon\,$.

With $k = \left\lceil \cfrac{x}{\{qz\}}\right\rceil$ it follows that $k \{qz\} \in (x,x+\{qz\}) \subseteq (x,x+\epsilon)\,$.

But $k \{qz\} = k(qz-p) = kqz - kp = \{kqz\}\,$, so in the end $\{nz\} \in (x,x+\epsilon)$ for $n = k q\,$.


[ EDIT ]  Below is a fully worked out example for $z = \varphi \simeq 1.618\dots$ with $x=0.5$ and $\epsilon=0.01\,$.

  • The convergents of $\varphi$ are ratios of consecutive Fibonacci numbers, and the first one with denominator greater than $1 / \epsilon = 100$ is $\cfrac{p}{q}=\cfrac{233}{144}\,$.

  • $144 \varphi -233=-0.003\dots \lt 0\,$, so we choose the opposites as $q,p$ i.e. $q=-144, p=-233\,$.

  • $k = \left\lceil \cfrac{0.5}{-144 \varphi+233} \right\rceil = \left\lceil 160.998\dots \right\rceil = 161\,$.

  • $n = kq = 161 \cdot (-144) = -23184$ and, indeed, $-23184 \varphi = -37512.499995\dots\,$, which has a fractional part of $\{-23184 \varphi\} = 0.5000048\dots \in (0.5, \,0.51)\,$.

Note #1: the above assumes that the fractional part is defined as $\{x\} = x - \lfloor x \rfloor\,$, including for negative numbers. In case of alternative definitions, the formula for $k$ would need to be adjusted.

Note #2: since the question was tagged as programming, too, it may be worth noting that this method gives an eligible, yet quite conservative $n\,$, usually a lot larger than the best (smallest) possible $n\,$. For example, working out the $z = \pi$ case this way yields $n = 57 \cdot 106 = 6042\,$, which is in fact correct, but far up from the $n=53$ shown in Will Jagy's answer.

  • 0
    "Integers p,q can be derived from the convergents of the continued fraction of z." this is the part I need.2017-01-26
  • 1
    @JorgeFernándezHidalgo There are a couple of references [here](http://math.stackexchange.com/questions/1979089/making-dirichlets-approximation-theorem-constructive-via-continued-fractions), with the Hardy and Wright Theorem 164 available [here](https://archive.org/stream/Hardy_and_Wright_-_Introduction_to_the_Theory_of_Numbers#page/n151/mode/2up). The inequality is satisfied once the denominator of the convergent exceeds $N$.2017-01-26
  • 1
    Thank you very much, I need to think this a bit.2017-01-26
  • 1
    @JorgeFernándezHidalgo Thanks. I added a worked-out example and a couple more notes.2017-01-26
2

For a treatment without continued fractions, see Diophantine Approximations by Niven.

Well, I did an example with $x + \frac{\epsilon}{2}= 1/2$ and $z=\pi.$ I wanted to get $$ n \pi - m - \frac{1}{2} = n \pi - \frac{2m+1}{2} $$ small, or $$ \pi - \frac{2m+1}{2n} $$ very small. The first convergent to $\pi$ with odd numerator and even denominator was $333/106,$ and we do get $$ 53 \pi \approx 166.50441 $$ which is pretty good.

Needs work

  • 0
    thanks, so the numerator is irrelevant? Oh, this makes a ton of sense. I need to re-read about continuous fractions, I was a complete noob back when I took that course.2017-01-26
  • 0
    so then we just take the denominator of the continuous fraction of $x+ \epsilon$ up to a point? right?2017-01-26
  • 0
    I'm a little wary of the quantity $(x + \epsilon/2)/z$. The question is completely insensitive to the integer part of $z$, but the continued fraction seems to depend substantially on it (at least when $x + \epsilon/2$ is not well-approximated by rationals?2017-01-26
  • 1
    @ErickWong I dropped that part, it is not the way the example went at all. There are still potential problems if there are congruences that the convergent entires cannot satisfy, in that case maybe switching to a nearby rational might be needed.2017-01-26
  • 0
    @jorge look at the example I did. Some thought may be required for each new $z$2017-01-26