2

A problem asks the following

Compute $\sqrt{4321} - \sqrt{4318}$ using 4 decimal digit arithmetic.

This comes out to $0.02,$ when the exact result should be $0.02282...$. It then asks the following,

Reformulate the expression $\sqrt{x} - \sqrt{y}$ with $x, y \in \Bbb{Z}$ very similar in size such that the answer produced is more accurate than in the above computation.

I'm unsure of what is even being asked here. Am I to do some analysis on the function $f(x,y) = \sqrt{x} - \sqrt{y}$ or am I missing something?

Thanks for any pointers.

Edward Evans
  • 4,590

3 Answers3

4

Hint: $\sqrt{x} - \sqrt{y} = \dfrac{x-y}{\sqrt{x}+\sqrt{y}}$, which is much better because there is little cancellation.

user21820
  • 57,693
  • 9
  • 98
  • 256
3

$$\sqrt x-\sqrt y=\frac{x-y}{\sqrt x+\sqrt y}$$

In the given example one can do $$\sqrt{4321}-\sqrt{4318}=\frac {3}{\sqrt x+\sqrt y}\approx \frac{3}{2\sqrt{4321}}\approx 0.02281$$ Optionally $$\frac{3}{2\sqrt{4318}}\approx0.02282$$

Piquito
  • 29,594
1

Hint: Write $x=y+t$ and expand $\sqrt{y+t}$ in a Taylor series in $t$ around $t=0$.

The first term after $\sqrt y$ is $ \dfrac{t}{2 \sqrt y} $. Use more terms if you need.

lhf
  • 216,483
  • Your method is no better than mine in terms of precision, since to find $t$ you will also have loss of precision if $x,y$ are not special such as integers. However, indeed Taylor expansion is the general way to systematically separate out significant terms that can be cancelled exactly, which in this case is $\sqrt{y}$. My method is ad-hoc and works better on this problem but does not extend to other problems. – user21820 Apr 19 '16 at 11:43
  • I like both answers but this seems more intuitive to me in terms of extension to other problems. Thanks for your answer though. – Edward Evans Apr 19 '16 at 11:50
  • @Ed_4434: In fact I recommend always using Taylor expansions to understand the asymptotic behaviour. My answer is more tailored to elementary level (like for high-school). =) – user21820 Apr 19 '16 at 11:56
  • Yeah that's fine, thanks anyway! – Edward Evans Apr 19 '16 at 12:00