Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I am trying to determine some numerical difficulties that arise from a couple problems, and a good way to re-write them to avoid those errors.

For instance, I have:

1) $\sqrt{x+\dfrac{1}{x}} - \sqrt{x-\dfrac{1}{x}}$ where $x\gg 1$

I think that since these two terms approximately equal each other, there will be cancellation error. So I multiplied the numerator and denominator by the conjugate yielding:

$\dfrac{\dfrac{2}{x}}{\sqrt{x+\dfrac{1}{x}}+\sqrt{x-\dfrac{1}{x}}}$

I think that this should get rid of the cancellation error, does anyone see anything wrong with this attempt?

If this looks right, then I will show my attempt on the second problem, but I hope to verify my method first.

2) $\sqrt{\dfrac{1}{a^2}+\dfrac{1}{b^2}}$ where $a\approx 0$ and $b\approx 1$

Thanks!

share|improve this question
    
There was no complex conjugate. Just saying. –  VF1 Aug 26 '12 at 20:33
    
Haha thanks! I edited it, I just meant conjugate –  Samuel Gregory Aug 26 '12 at 20:34
    
Yes, your answer to (1) is correct. –  Robert Israel Aug 26 '12 at 21:14
    
I don't see a way to do 2) in the same way. There is not a conjugate of it that would make things disappear. –  Samuel Gregory Aug 26 '12 at 21:16
    
Is there really a need to do anything in (2)? There is no cancellation to worry about here. –  Robert Israel Aug 26 '12 at 21:41

1 Answer 1

up vote 3 down vote accepted

For 1, you have successfully avoided the cancellation. If you want, you could go to $$\frac {\frac 2x}{\sqrt x (\sqrt{1+\frac 1{x^2} }+\sqrt{1-\frac 1{x^2} })}=\frac 2{x^{\frac 32} (\sqrt{1+\frac 1{x^2} }+\sqrt{1-\frac 1{x^2} })}\approx x^{-\frac 32}$$ but I am not sure that is an improvement.

For 2, you could have $\frac 1{a^2}$ overflow where $\frac 1a$ does not. To avoid this, you could rewrite it as $\frac 1a \sqrt {1+\frac {a^2}{b^2}}$. That still squares $a$, but if it underflows maybe it gets set to zero and you are OK.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.