Derive $\log(a+b)=\log(a)-2\log\left(\cos\left(\arctan\left(\sqrt{\frac{b}{a}}\right)\right)\right)$

In the comments section of another post, MATHEMATIKER stated that

$$\log(a+b)=\log(a)-2\log\left(\cos\left(\arctan\left(\sqrt{\frac{b}{a}}\right)\right)\right)$$

if $b>a>0$.

I wish to know how this was derived, and if it can be extended to $b,a\in\mathbb{C}$.

Solutions Collecting From Web of "Derive $\log(a+b)=\log(a)-2\log\left(\cos\left(\arctan\left(\sqrt{\frac{b}{a}}\right)\right)\right)$"

Nothing too magical is happening – it’s just a few more mundane substitutions used in a surprising way. The first one is that we have $$\cos(\arctan(x))=\frac{1}{\sqrt{1+x^2}}$$
which can be seen easily from trigonometry – a right triangle with adjacent of length $1$ and opposite of length $x$ has that the tangent associated with the angle is $x$ and the cosine is $\frac{1}{\sqrt{1+x^2}}$. One can also retrieve this (up to sign) from the identities that $\sin(x)^2+\cos(x)^2=1$ and $\frac{\sin(x)}{\cos(x)}=\tan(x)$.

Then, the expression simplifies to
$$\log(a+b)=\log(a)-2\log\left(\frac{1}{\sqrt{1+b/a}}\right)$$
Noting that $2\log(x)=\log(x^2)$ we get:
$$\log(a+b)=\log(a)-\log\left(\frac{1}{1+b/a}\right)$$
and since $-\log\left(\frac{1}x\right)=\log(x)$ we have
$$\log(a+b)=\log(a)+\log(1+b/a)$$
and using $\log(x)+\log(y)=\log(xy)$ gives
$$\log(a+b)=\log(a)+\log(b).$$
So, the derivation of the expression is just all the steps I listed, run in reverse.

Nothing goes terribly wrong when we try to extend to the complex plane. The principal issue is that $\arctan$ and $\log$ both have multiple branches. If we choose the wrong branch of $\arctan$, we can change the sign of the composition $\cos(\arctan(x))$, but the magnitude will be right. The fact that $\log$ has multiple branches just means that we have to be careful of multiples of $2\pi i$ coming out.

$$\log(a+b)=\log(a)-2\log\left(\cos\left(\arctan\left(\sqrt{\frac{b}{a}}\right)\right)\right)$$

Start from RHS:

Let $\arctan \left(\sqrt{\frac{b}{a}}\right) = y$ $\implies \tan y = \sqrt{\frac{b}{a}}$

Using the theorem according to pythagoras:
$$\cos y = \frac{\sqrt{a}}{\sqrt{a+b}}$$

The equation then reduces to:

$$\log(a)-2\log\left(\cos y\right) =\log(a)-2\log\left(\frac{\sqrt{a}}{\sqrt{a+b}}\right) = \log(a)-\log\left(\frac{a}{a+b}\right)$$

$$\log(a)-\log\left(\frac{a}{a+b}\right) = \log(a) – \log (a) -(-\log(a+b))= \log(a+b) = \text{LHS}$$

By subtracting $\log a$,
$$ -\frac{1}{2}\log\left(1 + \frac{b}{a}\right) = \log\cos\arctan \sqrt{\frac{b}{a}}
$$
Using the identity $\cos\arctan x = 1/\sqrt{x^2 + 1}$,
$$
\log\cos\arctan \sqrt{\frac{b}{a}}
= \log \frac{1}{\sqrt{b/a + 1}}
= -\frac{1}{2} \log (1 + b/a)
$$
as desired.