4
$\begingroup$

Some motivation:

I have a (simplified) function $f(x) = \frac{k}x$, where $k$ is some real constant and $x$ is a real number. The result of the function, however, is always truncated to an integer for application purposes. Since I also use the inverse of this function and the inverse is a floating-point result, I want to know the maximum error caused by the conversion. This means I am looking for the largest value of ($x_2$-$x_1$) that will satisfy $f(x_1) - f(x_2) < 1$.

So the starting equation is this:

$k\cdot\left(\frac{1}{x_1}-\frac{1}{x_2}\right)<1$

which I can rewrite as

$k\cdot\left(\frac{x_2-x_1}{x_1\cdot x_2}\right)<1$

and now I (sort of conveniently) have

$(x_2-x_1)<\frac{x_1\cdot x_2}k$

My problem: I don't know what $x_1$ and $x_2$ are, nor do I care. I just know they are fairly close to each other, e.g., $x_2 - x_1 \ll 1$

Can someone point me in the right direction to my desired solution? Or perhaps my approach is totally wrong?

  • 0
    About your question: by denoting $x_2-x_1=a$, you get $x_2=a+x_1$ and then you have a<\frac{x_1(a+x_1)}{k}, which leads to the quadratic x_1^2+ax_1-ka>0. Finding the roots you get that this inequality holds iff x_1>\frac{-a+\sqrt{a^2+4ka}}{2} or x_1<\frac{-a-\sqrt{a^2+4ka}}{2}, where $a$ is the only value you care about.2011-05-05

0 Answers 0