During my preparation for an exam, I've come across an exercise that was focused on precision calculation with floating point numbers. It goes like this:
Consider the expression : $$\frac{1}{1-x}-\frac{1}{1+x}, x\neq \pm1$$ For what range of values $x$ is it difficult to compute the expression accurately in foating-point arithmetic? Give a re-arrangement of the terms such that, for the range of values from part (a), the computation is more accurate in foating-point arithmetic.
I have some basics covered on floating point number systems, so I've tried to set $\pm x=0.9999...$, with a different number of decimal digits. The calculations are indeed more and more imprecise, however I don't know if this is the only problematic 'range'. Also, I have no idea how to transform this expression to be more accurate. I have tried $\frac{2x}{1-x^{2}}$ and $e^{\ln{2x}-\ln(1-x^{2})}$, but the results were pretty much the same.
Thanks for help!