Integral of $~\int\frac{\sqrt{x^{2}+l^{2}}}{x}dx~$ I tried the substitution of the variable but it didn't work I need to derive the below RHS from the below LHS.
$$\int\frac{\sqrt{x^{2}+l^{2}}}{x}dx=\sqrt{x^{2}+l^{2}}-l\cdot\ln\left(\frac{l+\sqrt{x^2+l^2}}{x}\right)\tag{1}$$
$$x,l\in\mathbb R_{>0}\tag{2}$$
My tries are as below.
$$x=l\cdot\tan^{}\left(\theta_{}\right)\tag{3}$$
$$\frac{dx}{d\theta}=l\cdot\sec^{2}\left(\theta_{}\right)\tag{4}$$
$$dx=l\cdot\sec^{2}\left(\theta_{}\right)\cdot d\theta\tag{5}$$
$$\sqrt{x^{2}+l^2}=\sqrt{\left(l\cdot\tan^{}\left(\theta_{}\right)\right)^{2}+l^{2}}\tag{6}$$
$$=\sqrt{l^{2}\cdot\tan^{2}\left(\theta_{}\right)+l^{2}}\tag{7}$$
$$=\sqrt{l^{2}\left(1+\tan^{2}\left(\theta_{}\right)\right)}\tag{8}$$
$$=l\sqrt{1+\tan^{2}\left(\theta_{}\right)}\tag{9}$$
$$=l\sqrt{\sec^{2}\left(\theta_{}\right)}\tag{10}$$
$$=l\sec^{}\left(\theta_{}\right)\tag{11}$$
$$\therefore~~\int\frac{\sqrt{x^2+l^2}}{x}dx=\int\frac{l\sec^{}\left(\theta_{}\right)}{l\cdot\tan^{}\left(\theta_{}\right)}\left(l\cdot\sec^{2}\left(\theta_{}\right)\cdot d\theta\right)\tag{12}$$
$$=\int\frac{l\cdot\sec^{3}\left(\theta_{}\right)}{\tan^{}\left(\theta_{}\right)}d\theta\tag{13}$$
$$=l\int\frac{\sec^{3}\left(\theta_{}\right)}{\sin^{}\left(\theta_{}\right)\cdot\sec^{}\left(\theta_{}\right)}d\theta\tag{14}$$
$$=l\int\frac{\sec^{2}\left(\theta_{}\right)}{\sin^{}\left(\theta_{}\right)}d\theta\tag{15}$$
$$A:=\int\frac{\sec^{2}\left(\theta_{}\right)}{\sin^{}\left(\theta_{}\right)}d\theta\tag{16}$$
$$t=\sec^{}\left(\theta_{}\right)\tag{17}$$
$$\frac{dt}{d\theta}=\left(\cos^{-1}\left(\theta_{}\right)\right)'~~\leftarrow~~\text{Not a}~\arccos\left(\theta_{}\right). \tag{18}$$
$$=\left(-1\right)\left(\cos^{-2}\left(\theta_{}\right)\right)\left(-\sin^{}\left(\theta_{}\right)\right)\tag{19}$$
$$=\frac{\sin^{}\left(\theta_{}\right)}{\cos^{2}\left(\theta_{}\right)}\tag{20}$$
$$\frac{d\theta}{dt}=\frac{\cos^{2}\left(\theta_{}\right)}{\sin^{}\left(\theta_{}\right)}\tag{21}$$
$$d\theta=\left(\frac{\cos^{2}\left(\theta_{}\right)}{\sin^{}\left(\theta_{}\right)}\right)dt\tag{22}$$
$$\cos^{}\left(\theta_{}\right)=\sec^{-1}\left(\theta_{}\right)\tag{23}$$
$$\therefore~~\cos^{2}\left(\theta_{}\right)=\sec^{-2}\left(\theta_{}\right)\tag{24}$$
$$d\theta=\left(\frac{\sec^{-2}\left(\theta_{}\right)}{\sin^{}\left(\theta_{}\right)}\right)dt\tag{25}$$
$$A=\int\frac{\sec^{2}\left(\theta_{}\right)}{\sin^{}\left(\theta_{}\right)}d\theta=\int\frac{\sec^{2}\left(\theta_{}\right)}{\sin^{}\left(\theta_{}\right)}\left(\left(\frac{\sec^{-2}\left(\theta_{}\right)}{\sin^{}\left(\theta_{}\right)}\right)dt\right)\tag{26}$$
$$=\int\frac{1}{\sin^{2}\left(\theta_{}\right)}dt~~\leftarrow~~\text{Not good}\tag{27}$$
How should I've done of the integration by substitution?
 A: $
\newcommand{\t}{\theta}
\newcommand{\d}{\mathrm{d}}
\newcommand{\ds}{\displaystyle}
\newcommand{\I}{\mathcal{I}}
$
Begin with
$$A = \int \frac{\sec^2 \t}{\sin \t} \, \d \t$$
Use the Pythagorean identity $\sec^2 \t = 1 + \tan^2 \t$. Then with some algebra,
$$A = \underbrace{\int \csc \t \, \d \t}_{\ds =: \I_1} + \underbrace{\int \frac{\sin \t}{\cos^2 \t} \, \d \t}_{\ds =: \I_2}$$
$\I_2$ is trivial enough with the $u$-substitution $u := \cos \t$, which would give $\d u = - \sin \t \, \d \t$, so
$$\I_2 = - \int u^{-2} \, \d u = \frac{1}{u} + C = \frac{1}{\cos \t} +C = \sec \t + C$$
The first is a bit less trivial, but if you're familiar with the technique for solving $\int \sec(x) \, \d x$, it's quite similar. We have
$$\I_1 = \int \csc \t \frac{\csc \t + \cot \t}{\csc \t + \cot \t} \, \d \t$$
Use $u := \csc \t + \cot \t$; then $\d u = (- \csc^2 \t - \csc\t \cot \t) \, \d \t$, i.e. $-1$ times the numerator:
$$\I_1 = - \int \frac{1}{u} \, \d u = - \ln |u| + C = - \ln \big| \csc \t + \cot \t \big| + C$$
Therefore,
$$A = \sec \t - \ln \big| \csc \t + \cot \t \big| + C$$
Note that you had $\t = \arctan(x/\ell)$ and you can finish from here; what remains is basic trig and algebra.
A: There's also a very much simpler way .
In $I = \int \frac{  \sqrt{ x ^{2} + l ^{2}  }   }{  x  } dx $.
Multiply and divide by $\sqrt{x^2 + l^2} $,we get ,
$$I = \int  {\frac{x}{\sqrt{{x^2} + {l^2}}} }dx  + {l^2} \int \frac {dx}{x \sqrt {x^2 + l^2}} $$
Put $x^2 + l^2 = t^2$ into first term and $x=l \tan{\theta}$ in the second term ,we get
$$I = t + \ln { |\tan { \theta \over 2} | } + C $$ .
Now put the values and get the answer .
A: Let $x=\ell\tan\theta$ results in
$$
\int\frac{\sqrt{x^2+\ell^2}}x\,\mathrm{d}x=
\ell\int\frac{\sec^3\theta}{\tan\theta}\,\mathrm{d}\theta=\ell\int\frac{\sin\theta\,\mathrm{d}\theta}{\cos^2\theta(1-\cos^2\theta)}
$$
So letting $c=\cos\theta$ gives
$$
\dots=-\ell\int\frac{\mathrm{d}c}{c^2(1-c^2)}=-\ell\int\left(\frac1{c^2}+\frac1{1-c^2}\right)\,\mathrm{d}c
$$
which you should know how to integrate.
Alternatively, let $x=\ell\sinh t$ gives
$$
\int\frac{\sqrt{x^2+\ell^2}}x\,\mathrm{d}x=
\ell\int\frac{\cosh^2 t}{\sinh t}\,\mathrm{d}t=
\ell\int\left(\sinh t+\frac1{\sinh t}\right)\,\mathrm{d}t
$$
etc.
Or you can let $x=\ell\cdot\frac{2t}{1-t^2}$, etc.
A: In this answer, I wanted to show that it is possible to use an algebraic substitution.
Take $$u=x+\sqrt{x^2+l^2}$$ then we have,
$$\begin{align}&u-x=\sqrt{x^2+l^2} \\ \implies 
&x^2+l^2=(u-x)^2\\ \implies 
&l^2=u^2-2ux \\ \implies 
&x=\frac{u^2-l^2}{2u}\end{align}$$
and
$$\mathrm{d}x=\frac{l^2+u^2}{2u^2}$$
Finally,
$$\begin{align}\int\frac{\sqrt{x^{2}+l^{2}}}{x}\mathrm {d}x=\frac 12 \int \frac{(u^2+l^2)^2}{u^2(u^2-l^2)}\mathrm{d}u=\frac 12 \int \left(-\frac{l^2}{u^2} + \frac{2 l}{u-l} - \frac{2 l}{u+l} + 1\right) \mathrm{d}u\end{align}$$
A: *Another way to do it.$
Let $$u=\sqrt{x^2+l^2}\implies du=\frac{x}{\sqrt{x^2+l^2}}dx$$
$$\int\frac{\sqrt{x^{2}+l^{2}}}{x}dx=\int\frac{u^2}{u^2-l^2}\,du=\int\frac{u^2-l^2+l^2}{u^2-l^2}\,du=\int du+l ^2 \int\frac{du}{(u+l)(u-l)}$$ Using partial fraction decomposition
$$\frac{1}{(u+l)(u-l)}=\frac 1{2l} \left(\frac 1{u-l}-\frac 1{u+l} \right)$$ which becomes to be quite simple.
When back to $x$, simplify the logarithms.
