2

Lets say $r$ is a real number and $I_1, I_2$ are integers. I want this, $$r*I_1=I_2$$ This is not possible all the time so, I allow to add an epsilon $\epsilon$ to the real number such that $$(r+\epsilon)*I_1 = I_2$$ What is the smallest value of $\vert\epsilon\vert$ ? For example: $r = 0.31, I_1 = 30 \therefore \epsilon = -0.01, I_2 = 9$

I can solve the problem numerically. That is, I consider only two decimal precision and search for the smallest $\epsilon$.

As in the example, I round lets say $r=0.3111$ to $r=0.31$ and multiply it by $I_1$ if the result is an integer I stop or $r := r \pm 0.01$ then do the previous steps.


$ I_1 \in \{24, 25, 30, 48, 50, 60\}$ and $r$ is given. We are seeking for smallest $\vert\epsilon\vert$ and $I_2$ is the output. Any $I_2 \ge 0$ is acceptable.

  • If you allow bigger and bigger $I$, then you need smaller and smaller $\epsilon$. For instance, if $I_1 = 10$, then for any $r$ we get $|\epsilon|\leq 0.05$, while if $I_1 = 100$, then $|\epsilon|\leq 0.005$. You need to have a limit like $|I_1|\leq n$ or something before we can say anything about $\epsilon$. – Arthur Aug 17 '17 at 13:45
  • If you have $(r+\varepsilon)I_1=I_2$ then you have $sI_1=I_2$ where $s=r+\varepsilon$ is a real number. – Dave Aug 17 '17 at 13:45
  • @Arthur I updated the question as you suggest. – top secret Aug 17 '17 at 13:49
  • You can throw away $24,25$ and $30$, since if a given $\epsilon$ works with any of those, it's going to work with $48,50$ or $60$ as well. – Arthur Aug 17 '17 at 14:28

3 Answers3

1

The value of $|\epsilon|$ can be arbitrarily small if you pick $r$ correctly, given the integers $I_1,I_2$. The choice of $r=\frac{I_2}{I_1}-\epsilon$ for any arbitrarily small $\epsilon$ says that $|\epsilon|$ can be as small as we like.

0

One way to reduce the trial and error is to find the continued fraction for $r$. Terminating the continued fraction expression gets you good rational approximations to $r$, which you can check and see if the error is small enough or the denominator is in the range you want.

Ross Millikan
  • 374,822
0

Assume for now that both $r$ and $I_1$ are given.

Consider the real value $r*I_1$. Let $I_2=[r*I_1]$ be the nearest integer, i.e. the integer you get when rounding $r*I_1$. Then $\epsilon=I_2/I_1 - r$ is the smallest change that makes $(r+\epsilon)*I_1$ an integer.

You have several choices for the value of $I_1$, so simply calculate $\epsilon = [r*I_1]/I_1 - r$ in each of those cases and choose the best one.