How can we avoid the cancellation error while computing $f(x)=\sqrt{1+x^2}-1$ for small $|x|$ values? In order to compute the condition number of the function, I found the derivative of the function but I cant simplify it for obtaining the condition number. How can I solve this?
$$ CN=\left|\frac{x f'(x)}{f(x)}\right| $$
The usual binomial trick gives the alternative form $$ f(x)=\frac{x^2}{\sqrt{1+x^2}+1} $$ I think that catastrophic cancellation invalidates the computation of the condition number per derivative. The absolute error of the first formula is about $(\sqrt{1+x^2}+1)\mu$.
Taking the above formula as (almost) exact, one can compute the relative error of the first formula. This gives the following loglog plot.