3

For the function $f(x)=\sqrt{x^2+1}-x$, have computed $f(100)=0$ using 4-digit decimal arithmetic (rounding after every intermediate calculation). The value $f(100) = 0.0049998750$ (to 8sf) is given and I have computed a relative error of $1$ using this.

Next I am asked to arrange the computation of $f(x)$ so that the loss of significant digits can be reduced for large values of $x$. Hence compute a value for $f(100)$ using 4-digit decimal arithmetic with significantly smaller relative error than the value previously obtained.

I have tried using a series expansion and also writing $\sqrt{x^2+1}$ as $\sqrt{x(x+1/x)}$ but end up with either $f(100)=0$ again or a ridiculously large number.

Could anyone please help?

1 Answers1

2

Note that $$ \left(\sqrt{x^2+1}-x\right)\left(\sqrt{x^2+1}+x\right)=\left(x^2+1\right)-x^2=1,$$ hence for $x\gg 0$ (heck, you should in fact do so for all $x>0$ to avoid subtraction) use $$\sqrt{x^2+1}-x=\frac1{\sqrt{x^2+1}+x}$$ to calculate your function. Then $$f(100)=\frac1{\sqrt{100^2+1}+100}=\frac1{\sqrt{10001}+100}\approx\frac1{\sqrt{10000}+100}=\frac1{100+100}=0.005$$

In fact, if $x\ge10^2$ this essentially uses $f(x)=\frac1{2x}$ as approximation.