TITLE: Derivative of $\arctan2$
QUESTION [6 upvotes]: I'm currently working on some navigation equations and I would like to write down the derivative with respect to $x$ of something like $$f(x) = \arctan2(c(x), d(x))$$ 
I've searched wherever I've could and the only thing I've come across are the partial derivatives of $\arctan2(y,x)$  with respect to $x$ and $y$. 
To be more especific, my equation looks like this:
$$\psi = \arctan2 \left ( -m_y \cos(\phi + \delta \phi) + m_z \sin(\phi + \delta \phi) \ , \ m_x \cos(\theta + \delta \theta) + m_y \sin(\psi + \delta \psi) \sin(\theta + \delta \theta) + m_x \cos(\phi + \delta \phi) \sin(\theta + \delta \theta)  \right )$$
and I want to know
$$\frac{\partial \ \psi}{\partial \ \delta  \phi} \text{ and } \frac{\partial \ \psi}{\partial \ \delta  \theta}$$
I've tried to rewrite the epxression to some conditional that checks if $d(x) < 0$, and if so it sums $\pi$ to $\tan(c(x),d(x))$. The thing is that the condition depends on both $\delta \theta$ and $\delta \phi$ and I don't know how to derive it. 
Both $\delta \theta$ and $\delta \phi$ may be assumed to be very small angles.
I don't know for sure if the expressions I want exist. I've got no problem in using conditionals as long as the expressions I want are in closed-form. All suggestions are appreciated. Thank you in advance.

REPLY [2 votes]: Let's begin by assuming you know that$$\partial_cf=\frac{d}{c^2+d^2},\,\partial_df=\frac{-c}{c^2+d^2}.$$Dividing the chain rule $\operatorname{d}f=\partial_cf\operatorname{d}c+\partial_df\operatorname{d}d$ by $\operatorname{d}x$ gives$$f^\prime=\frac{c^\prime d-cd^\prime}{c^2+d^2}.$$