4

For $x \approx y$, how may we avoid loss of significance errors in computing $\tan(x) - \tan(y)$?

I don't think Taylor polynomials will be useful here, so I am thinking the answer lies in some sort of trig identity trick. I have managed to get the approximation $$\tan(x) - \tan(y) \approx \frac{4 \sin(x) \sin(y)}{\sin(2x) \sin(2y)} (x - y)$$ for $x \approx y$, but I'm not sure that this helps, as it still contains the quantity $x - y$, which could introduce loss of significance errors itself. Thank you for any help!

tylerc0816
  • 4,123
  • 1
    Assume there was a better way to compute $\tan x - \tan y$. Then you would have discovered a way to nicely compute $x-y=\frac{\sin(2x)\sin(2y)}{4\sin(x)\sin(y)}(\tan(x)-\tan(y))$ with less loss of signoificance error. Go figure. – Hagen von Eitzen Jan 27 '13 at 12:11

2 Answers2

5

As Hagen van Eitzen has remarked, if $x$ and $y$ are approximately equal there is bound to be some significance loss. But in the difference $\ \tan x-\tan y\ $ there is the additional loss caused by $\tan$ becoming large near odd multiples of ${\pi\over 2}$. The latter can be avoided by writing $$\tan x-\tan y={\sin(x-y)\over\cos x\cos y}\ .$$

5

Maybe I'm being too simplistic here, but what about a simple first order approximation? Assume $x=y+\delta$:

$$\tan{(y+\delta)}-\tan{y} \approx (\sec^2{y}) \: \delta$$

Ron Gordon
  • 138,521
  • Or to order 2: $\delta \left(\tan ^2(y)+1\right)+\delta ^2 \left(\tan ^3(y)+\tan (y)\right)+...$ I think yours is the right way to go. – Nathaniel Bubis Jan 27 '13 at 13:10