# How to prove that one formula is numerically better than another

If $\mathbf{u}$ and $\mathbf{v}$ are vectors in real 3-dimensional space, here are two formulas for computing the angle between them:

$$\theta = \operatorname{atan2}\left( \|\mathbf{u}\times\mathbf{v}\|, \mathbf{u}•\mathbf{v} \right)$$

$$\theta = 2\, \operatorname{atan2}\left( \left\| \, \|\mathbf{v}\|\,\mathbf{u} - \|\mathbf{u}\|\,\mathbf{v}\, \right\|, \left\|\, \|\mathbf{v}\|\,\mathbf{u} + \|\mathbf{u}\|\,\mathbf{v}\,\right\| \right)$$

An answer to this question gives a sort of hand-waving argument that the first formula is inferior due to the cancellations involved in the computation of the cross product. Is there an objective way to demonstrate that one formula is numerically superior to the other?

For this specific question, they're both based on $$atan2$$, so it comes down to proving things about the accuracy of the arguments. These types of proofs generally involve writing the computed operations (multiply, addition, subtraction etc.) in terms of their exact value plus error terms, and then showing that the accumulated error from one formula must be >= the error of the other.