# Loss Of Significance Error For: $\tan(x) - \tan(y)$

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!

-
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

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$$

-
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. – nbubis Jan 27 '13 at 13:10

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}\ .$$

-
I apologize for this stray comment but would you mind if I send you a more general email(which I shall not disclose in public)?(for reference,I am in high school).(I didn't want to send an unsolicited email). – user54807 Jan 27 '13 at 15:22
My potential email is not related to this post. – user54807 Jan 27 '13 at 15:28
@Worker: Send it, and I will see. – Christian Blatter Jan 27 '13 at 16:04
That is very kind of you.I have sent it. – user54807 Jan 27 '13 at 16:38