Prove an identity concerning the rounding of a number Given $x, rd(x) > 0,$ where $rd$ is a rounding function of a given decimal number $x$ at a certain decimal place ($rd(x) = x(1+\epsilon_x), \, |\epsilon_x|\leq eps$), and $eps$ is the machine precision, I need to prove the relation: $$\frac{|x-rd(x)|}{|x|} = \frac{|x-rd(x)|}{|rd(x)|} + o(eps).$$ I first proved the following estimation $$\frac{|x-rd(x)|}{|x|} \leq \frac{|x-rd(x)|}{|rd(x)|}(1+eps).$$ I thought it would not be difficult to bound the expression I want to prove from above and below with the right hand side of this inequality, from which then it would follow the identity I want to prove. But this proved to be difficult. Can you provide any insight or a solution proposal ? Thanks.
 A: I shall write $\hat{x} = \text{rd}(x)$ as this is slightly faster to type. I shall use $u$ to denote the unit roundoff, because I associate $\text{eps}$ with $\epsilon$ and machine epsilon is the distance between $1$ and the next floating point number which is 1+2u, so that $\epsilon = 2u$. I shall make the very mild assumption that $u<1$.

In any case, there is a $\delta$ such that $$\hat{x} = x(1+ \delta), \quad |\delta| \leq u$$ where $u$ is the unit roundoff. Our objective is to show that 
$$ \frac{\left| \left| \frac{x - \hat{x}}{x} \right| -  \left| \frac{x - \hat{x}}{\hat{x}} \right| \right| }{u} \rightarrow 0, \quad u \rightarrow 0, \quad u > 0.$$ We shall apply the triangle inequality $||a| - |b|| \leq |a-b$| which is why we first explore the expression $$\alpha = \frac{x-\hat{x}}{x} - \frac{x-\hat{x}}{\hat{x}}$$ before applying the absolute value function. We have $$\alpha = \frac{\hat{x}(x-\hat{x}) - x(x-\hat{x})}{x\hat{x}} = \frac{-\hat{x}^2 + 2x\hat{x} - x^2}{x\hat{x}} = \frac{-(x-\hat{x})^2}{x\hat{x}} = \frac{-(-\delta x)^2}{x\hat{x}} = -\frac{\delta^2 x}{\hat{x}} = -\frac{\delta^2}{1+\delta}$$
It follows that 
$$ \left| \left| \frac{x - \hat{x}}{x} \right| -  \left| \frac{x - \hat{x}}{\hat{x}} \right| \right| \leq |\alpha| = \frac{\delta^2}{1 + \delta} \leq \frac{u^2}{1-u}$$
and an application of the squeeze lemma now yields the desired result.
 This is actually an interesting and slightly surprising result. The standard analysis of the floating point representation of a real number shows that $$ \left|\frac{x - \hat{x}}{x}\right| \leq u$$ and also $$ \left|\frac{x - \hat{x}}{\hat{x}} \right| \leq u,$$ but these inequalities only yield
$$ \left| \left| \frac{x - \hat{x}}{x} \right| -  \left| \frac{x - \hat{x}}{\hat{x}} \right| \right| \leq 2u $$ 
which is inadequate for the task that was hand.
