How can the values of the function $f(x) = \sqrt{x + 2} −\sqrt{x}$ be computed accurately when $x$ is large?
I have tried using Matllab. I am not able to understand when $x$ will be large.
How can the values of the function $f(x) = \sqrt{x + 2} −\sqrt{x}$ be computed accurately when $x$ is large?
I have tried using Matllab. I am not able to understand when $x$ will be large.
On
Recall that when $t$ is small, $\sqrt{1+t}\approx 1 + t/2$. It follows that, for $x$ large and positive, $$ f(x)= \sqrt{x}(\sqrt{1+2/x}-1)\approx 1/\sqrt{x}, $$ in the sense that $f(x)\sqrt{x}\rightarrow 1$ as $x\rightarrow \infty$.
On
In fact, an asymptotic expansion of $f(x) = \sqrt{x+a} - \sqrt{x}$ about $x = \infty$ is $$f(x) \approx \frac{a}{2} x^{-1/2} - \frac{a^2}{8} x^{-3/2} + \frac{a^3}{16} x^{-5/2} - \frac{5a^4}{128} x^{-7/2} + \frac{7a^5}{256} x^{-9/2} - \frac{21a^6}{1024} x^{-11/2} + \cdots.$$ We can calculate this via the generalized binomial theorem $$(a+x)^r = \sum_{k=0}^\infty \binom{r}{k} a^k x^{r-k},$$ for $r = 1/2$, so that in particular, $$\begin{align*} \binom{1/2}{k} &= \frac{(1/2)(1/2-1)\cdot \ldots \cdot(1/2-k+1)}{k!} \\ &= \frac{1(-1)(-3)\cdot \ldots \cdot(3-2k)}{2^k k!} \\ &= (-1)^{k-1} \frac{(2k-2)!}{2^{2k-1} k! (k-1)!} \\ &= \frac{(-1)^{k-1}}{2^{2k-1}k } \binom{2k-2}{k-1}, \quad k = 1, 2, \ldots,\end{align*}$$ and $\binom{1/2}{0} = 1$.
On
This is a variant of heropup's answer; hopefully the useful technique it illustrates justifies the partial duplication.
We may factor $\sqrt{x+2} -\sqrt{x} = \sqrt{x}( \sqrt{1 + 2/x} - 1).$ Now if $x \to \infty,$ then $|2/x| < 1,$ so we can compute $\sqrt{1 + 2/x}$ via the binomial theorem, to get $$\sqrt{1+ 2/x} - 1 = \sum_{n = 1}^{\infty} {{1/2} \choose n } \dfrac{2^n}{x^n} = \sum_{n = 1}^{\infty} (-1)^{n-1}\dfrac{(2n-3)\cdot (2n - 5) \cdots 3 \cdot 1 }{n!} x^{-n},$$ so that $$\sqrt{x+2} - \sqrt{x} = \sum_{n = 1}^{\infty} (-1)^{n-1}\dfrac{(2n-3)\cdot (2n - 5) \cdots 3 \cdot 1 }{n!} x^{-\frac{2n-1}{2}}.$$
Of course this is the same series as in heropup's answer, derived in essentially the same way. But one thing we see, by applying the binomial theorem to $1 + 2/x,$ is that this series converges for $|2/x| < 1,$ i.e. for $x > 2,$ which might be helpful. (And of course one can use the usual theory of Taylor series to estimate the rate of convergence, if necessary.)
The general technique this illustrates is doing a division by the term that is going to infinity, so that instead one has a term which is going to zero.
If directly computing $\sqrt{x+2}-\sqrt{x}$ is giving you problems, you can instead try using
$\sqrt{x+2}-\sqrt{x} = \dfrac{(\sqrt{x+2}-\sqrt{x})(\sqrt{x+2}+\sqrt{x})}{\sqrt{x+2}+\sqrt{x}} = \dfrac{(x+2)-x}{\sqrt{x+2}+\sqrt{x}} = \dfrac{2}{\sqrt{x+2}+\sqrt{x}}$.
For large $x$, this is approximately $\dfrac{2}{\sqrt{x}+\sqrt{x}} = \dfrac{1}{\sqrt{x}}$.
EDIT: I just tried this for $x = 10^{18}$ using MATLAB R2013b.
For $\sqrt{x+2}-\sqrt{x}$ it gives $0$, but for $\dfrac{2}{\sqrt{x+2}+\sqrt{x}}$, it gives $1.0000 \times 10^{-9}$.