I'm trying to think through the sensitivity of atan2 to errors in its inputs and I've run into a disconnect that I don't quite understand.
I know that you can compute the relative condition number of a differential function $f$ as:
$$\kappa(\vec{x}) = \frac{\Vert\mathbb{J}_f(\vec{x})\Vert}{\Vert f(\vec{x})\Vert/\Vert \vec{x}\Vert}$$
Where the norm on the Jacobian is the induced norm.
For $atan(x)$ you end up with simply the derivative $\frac{1}{1+x^2}$ so it works out to: $$\kappa(x) = \frac{x}{(1+x^2)atan(x)}$$
Which is very nicely behaved:
If I look at it on the unit circle and compute K(y/x), it looks well behaved too:
However, looking at atan2(y,x) = atan(y/x), you end up with:
$$\mathbb{J}(y,x) = \{\frac{-y}{x^2+y^2}, \frac{x}{x^2+y^2}\}$$
It turns out the induced $L_2$ norm for this is 1, and in my particular case, my x and y values are indeed a sine and cosine pair so $\Vert <x,y>\Vert = \sqrt{x^2+y^2} = 1$
This leaves you with $\kappa(y,x) = \frac{1}{\vert atan2(y,x)\vert}$ which is less well behaved for positive x and y near zero:
I believe the math here but I'm struggling to interpret the results in a consistent way, since atan2 is fundamentally just atan with logic to interpret the sign correctly.
Why does atan2 seem to get very sensitive near zero and atan doesn't?
Edit: Made atan2 and related equations consistently (y,x) order.