# How do you evaluate the integral int cos^2(lnx)?

Jan 29, 2017

$\frac{1}{10} x \cos \left(2 \ln x\right) + \frac{1}{5} x \sin \left(2 \ln x\right) + \frac{1}{2} x + C$

#### Explanation:

$I = \int {\cos}^{2} \left(\ln x\right) \textcolor{red}{\mathrm{dx}}$

First, let $t = \ln x$. This implies that $x = {e}^{t}$ and that $\mathrm{dt} = \frac{1}{x} \mathrm{dx}$. Then:

$I = \int {\cos}^{2} \left(\ln x\right) \left(x\right) \left(\frac{1}{x} \mathrm{dx}\right)$

$I = \int {\cos}^{2} \left(t\right) {e}^{t} \mathrm{dt}$

From the identity $\cos \left(2 t\right) = 2 {\cos}^{2} \left(t\right) - 1$, we write that ${\cos}^{2} \left(t\right) = \frac{1}{2} \cos \left(2 t\right) + \frac{1}{2}$. Then:

$I = \int \left(\frac{1}{2} \cos \left(2 t\right) + \frac{1}{2}\right) {e}^{t} \mathrm{dt}$

$I = \frac{1}{2} \int {e}^{t} \cos \left(2 t\right) \mathrm{dt} + \frac{1}{2} \int {e}^{t} \mathrm{dt}$

$I = \frac{1}{2} \int {e}^{t} \cos \left(2 t\right) \mathrm{dt} + \frac{1}{2} {e}^{t}$

Let $J = \int {e}^{t} \cos \left(2 t\right) \mathrm{dt}$. This will be tackled in isolation. We will use integration by parts to solve it. Let:

$\left\{\begin{matrix}u = \cos \left(2 t\right) & \implies & \mathrm{du} = - 2 \sin \left(2 t\right) \mathrm{dt} \\ \mathrm{dv} = {e}^{t} \mathrm{dt} & \implies & v = {e}^{t}\end{matrix}\right.$

Then by the IBP formula:

$J = {e}^{t} \cos \left(2 t\right) + \int 2 {e}^{t} \sin \left(2 t\right) \mathrm{dt}$

Reapplying IBP to the remaining integral with new $u$ and $\mathrm{dv}$:

$\left\{\begin{matrix}u = 2 \sin \left(2 t\right) & \implies & \mathrm{du} = 4 \cos \left(2 t\right) \\ \mathrm{dv} = {e}^{t} \mathrm{dt} & \implies & v = {e}^{t}\end{matrix}\right.$

So:

$J = {e}^{t} \cos \left(2 t\right) + 2 {e}^{t} \sin \left(2 t\right) - 4 \int {e}^{t} \cos \left(2 t\right) \mathrm{dt}$

Notice that $J = \int {e}^{t} \cos \left(2 t\right) \mathrm{dt}$ has reappeared in the expression. We can now do some "integral algebra" to solve for $J$, the integral.

$J = {e}^{t} \cos \left(2 t\right) + 2 {e}^{t} \sin \left(2 t\right) - 4 J$

$5 J = {e}^{t} \cos \left(2 t\right) + 2 {e}^{t} \sin \left(2 t\right)$

$J = \frac{1}{5} {e}^{t} \cos \left(2 t\right) + \frac{2}{5} {e}^{t} \sin \left(2 t\right)$

Returning to $I$:

$I = \frac{1}{2} J + \frac{1}{2} {e}^{t}$

$I = \frac{1}{10} {e}^{t} \cos \left(2 t\right) + \frac{1}{5} {e}^{t} \sin \left(2 t\right) + \frac{1}{2} {e}^{t}$

Our original substitution was $t = \ln x$, also implying that $x = {e}^{t}$, so:

$I = \frac{1}{10} x \cos \left(2 \ln x\right) + \frac{1}{5} x \sin \left(2 \ln x\right) + \frac{1}{2} x + C$