Arctangent addition formula (source code)

= Arctangent addition formula
{title2=$\arctan A+\arctan B=\arctan((A+B)/(1-AB))\quad(AB<1)$}

For real $A,B$ with $AB<1$, the principal <inverse tangent> satisfies
$$
\boxed{\arctan A+\arctan B=\arctan\frac{A+B}{1-AB}.}
$$
To prove it, multiply the <complex numbers> $1+iA$ and $1+iB$. Their product is $(1-AB)+i(A+B)$, whose positive <real part> places its <complex argument> in $(-\pi/2,\pi/2)$. The individual <complex arguments> are $\arctan A$ and $\arctan B$, and their sum is in $(-\pi,\pi)$. Multiplication adds these <complex arguments>, so the positive <real part> forces the sum into the same principal range and gives the displayed formula.

If $AB>1$, both $A,B$ have the same sign. Add $\pi$ to the right-hand side when $A,B>0$, and subtract $\pi$ when $A,B<0$. If $AB=1$, the sum is $\pi/2$ or $-\pi/2$ according to the sign of $A+B$. These cases record the branch information that can be lost by applying the <tangent addition formula> alone.