Evaluate $\displaystyle \int \log \left(x + \sqrt{x^2 + a^2}\right) \; dx$
Let $I = \displaystyle \int \log \left(x + \sqrt{x^2 + a^2}\right) \; dx$ $\;\;\; \cdots \; (1)$
Let $x = a \; \tan \theta$ $\;\;\; \cdots \; (2a)$
Differentiating equation $(2a)$ gives
$dx = a \; \sec^2 \theta \; d\theta$ $\;\;\; \cdots \; (2b)$
$\therefore$ $\;$ In view of equations $(2a)$ and $(2b)$, equation $(1)$ becomes
$\begin{aligned}
I & = \int \log \left(a \; \tan \theta + \sqrt{a^2 \; \tan^2 \theta + a^2}\right) a \; \sec^2 \theta \; d\theta \\\\
& = a \int \sec^2 \theta \; \log \left(a \; \tan \theta + a \; \sec \theta\right) \; d\theta \\\\
& \left[\begin{aligned}
\text{Note: } & \int u \; v \; dx = u \int v \; dx - \int \left\{\int v \; dx \times \dfrac{d}{dx} \left(u\right) \right\} \; dx \\\\
& \text{Here } u = \log \left(a \; \tan \theta + a \; \sec \theta\right), \;\; v = \sec^2 \theta
\end{aligned}\right] \\\\
& = a \log \left|a \tan \theta + a \sec \theta\right| \int \sec^2 \theta \; d\theta \\
& \hspace{2em} - a \int \left[\int \sec^2 \theta \; d\theta \times \dfrac{d}{d\theta} \left[\log \left(a \tan \theta + a \sec \theta\right)\right]\right] \; d \theta \\\\
& = a \left\{\tan \theta \; \log \left|a \tan \theta + a \sec \theta\right| - \int \dfrac{\tan \theta \left(a \sec^2 \theta + a \sec \theta \tan \theta\right)}{a \left(\tan \theta + \sec \theta\right)} \; d \theta \right\} \\\\
& = a \left\{\tan \theta \; \log \left|a \tan \theta + a \sec \theta\right| - \int \dfrac{a \tan \theta \sec \theta \left(\sec \theta + \tan \theta\right)}{a \left(\tan \theta + \sec \theta\right)} \; d\theta \right\} \\\\
& = a \tan \theta \; \log \left|a \tan \theta + a \sec \theta\right| - a \int \tan \theta \; \sec \theta \; d\theta \;\;\; \cdots \; (3)
\end{aligned}$
$\begin{aligned}
\text{Consider } \int \tan \theta \; \sec \theta \; d\theta & = \int \dfrac{\sin \theta}{\cos \theta} \times \dfrac{1}{\cos \theta} \; d \theta \\\\
& = \int \dfrac{\sin \theta}{\cos^2 \theta} \; d \theta \;\;\; \cdots \; (4)
\end{aligned}$
Let $\cos \theta = t$ $\;\;\; \cdots \; (5a)$
Differentiating equation $(5a)$ gives
$- \sin \theta \; d\theta = dt$ $\implies$ $\sin \theta \; d\theta = - dt$ $\;\;\; \cdots \; (5b)$
In view of equations $(5a)$ and $(5b)$, equation $(4)$ becomes
$\begin{aligned}
\int \tan \theta \; \sec \theta \; d\theta & = \int \dfrac{- dt}{t^2} \\\\
& = \dfrac{1}{t} + c_1 \\\\
& = \dfrac{1}{\cos \theta} + c_1 \;\;\; \left[\text{from equation }(5a)\right] \;\;\; \cdots \; (6)
\end{aligned}$
$\therefore$ $\;$ In view of equation $(6)$, equation $(3)$ becomes
$I = a \; \tan \theta \; \log \left|a \tan \theta + a \sec \theta\right| - \dfrac{a}{\cos \theta} + c$ $\;\;\; \cdots \; (7)$
where $c = -a \; c_1$
Now, from equation $(2a)$,
$\tan \theta = \dfrac{x}{a}$ $\;\;\; \cdots \; (8a)$
$\sec \theta = \sqrt{1 + \tan^2 \theta} = \sqrt{1 + \dfrac{x^2}{a^2}} = \dfrac{\sqrt{x^2 + a^2}}{a}$ $\;\;\; \cdots \; (8b)$
Substituting equations $(8a)$ and $(8b)$ in equation $(7)$ gives
$I = a \times \dfrac{x}{a} \times \log \left|a \times \dfrac{x}{a} + a \times \dfrac{\sqrt{x^2 + a^2}}{a}\right| - a \times \dfrac{\sqrt{x^2 + a^2}}{a} + c$
i.e. $I = x \; \log \left|x + \sqrt{x^2 + a^2}\right| - \sqrt{x^2 + a^2} + c$