# How to finish this integral?

#### Pedro

##### New member
Hi, this is my first question in this forum.

Find $\int \cos(\ln x) \mathrm dx$.

I started by substitution. Let $u=\ln x$, so we get $\mathrm du=\frac{1}{x} \mathrm dx$ and $x=e^{u}$. Then the integral stays like this:

$$\int \cos(u)e^{u} \mathrm du$$

But now I can't managed how to finish. I've tryed integration by parts, but it seems like there is allways an integral remainingto integrate by parts.

Can you help me? Thanks

#### Opalg

##### MHB Oldtimer
Staff member
Hi, this is my first question in this forum.

Find $\int \cos(\ln x) \mathrm dx$.

I started by substitution. Let $u=\ln x$, so we get $\mathrm du=\frac{1}{x} \mathrm dx$ and $x=e^{u}$. Then the integral stays like this:

$$\int \cos(u)e^{u} \mathrm du$$

But now I can't managed how to finish. I've tryed integration by parts, but it seems like there is allways an integral remainingto integrate by parts.

Can you help me? Thanks
Hi Pedro and welcome to MHB.

You have made a good start on this problem, and you are right to use integration by parts on the integral $$\displaystyle \int \cos (u)\, e^{u}du$$ (integrating the exponential and differentiating the cosine). That will lead to something looking like $$\displaystyle \int \sin (u)\, e^{u}du$$. The trick now is to integrate that by parts (again integrating the exponential, and differentiating the sine). At first sight, this looks unpromising, because it leads you back to something looking very like what you started out with. But look at it more closely, and you will see that in fact it can be rearranged to give you a formula for $$\displaystyle \int \cos (u)\, e^{u}du$$.

#### Petrus

##### Well-known member
Hi, this is my first question in this forum.

Find $\int \cos(\ln x) \mathrm dx$.

I started by substitution. Let $u=\ln x$, so we get $\mathrm du=\frac{1}{x} \mathrm dx$ and $x=e^{u}$. Then the integral stays like this:

$$\int \cos(u)e^{u} \mathrm du$$

But now I can't managed how to finish. I've tryed integration by parts, but it seems like there is allways an integral remainingto integrate by parts.

Can you help me? Thanks
Hello Pedro,
I have not really spend time and check if this works but you should be able to use integrate by part with $$\displaystyle u=\cos(\ln x) <=> du = \frac{-\sin(\ln x)}{x} dx$$ and $$\displaystyle dv=dx <=>v=x$$ now when I think about this I think it will be infinity loop. Well I really don't have time to check this now as I have to go soon but I hope this is correctly as I remember from when I did one.

Edit: now when I read Opalg comment maybe my method is not valid.
Regards,
$$\displaystyle |\pi\rangle$$

##### Active member
Hi Pedro and welcome to MHB.

You have made a good start on this problem, and you are right to use integration by parts on the integral $$\displaystyle \int \cos (u)\, e^{u}du$$ (integrating the exponential and differentiating the cosine). That will lead to something looking like $$\displaystyle \int \sin (u)\, e^{u}du$$. The trick now is to integrate that by parts (again integrating the exponential, and differentiating the sine). At first sight, this looks unpromising, because it leads you back to something looking very like what you started out with. But look at it more closely, and you will see that in fact it can be rearranged to give you a formula for $$\displaystyle \int \cos (u)\, e^{u}du$$.
Just to elaborate on Opalg's tip: after substituting $t = \ln(x)$, you correctly ended up with
$$\int \cos (t)\, e^{t}dt$$
Now to do integration by parts, begin by proceeding as usual. Take:
$$u = \cos(t)\\ du = -\sin(t)\,dt\\ dv = e^t dt\\ v = e^t$$
And you end up with
$$\int \cos (t)\, e^{t}dt = e^t \cos(t) - \int (-\sin(t)\,e^t dt)\\ =e^t \cos(t) + \int \sin(t)\,e^t dt$$
Now, in order to do the second integral, we once again integrate by parts, taking
$$u = \sin(t)\\ du = \cos(t)\,dt\\ dv = e^t dt\\ v = e^t$$
and ending up with
$$\int \sin(t)\,e^t dt = \sin(t)e^t - \int \cos(t)e^t dt$$
Which, substituting the above back in, gives us
$$\int \cos (t)\,e^t dt = e^t \cos(t) + \sin(t)e^t - \int \cos(t)e^t dt$$
As you indicated, if we were to continue with integration by parts, the process would never end since we have come full circle. What we will do instead at this point is make the above into an algebra problem. Defining $I = \int \cos(t)e^t dt$ to be our integral, we can rewrite the above equation as
$$I = e^t \cos(t) + \sin(t)e^t - I + C$$
From there, we can simply solve for $I$. We find
$$2I = 2\left[\int \cos(t)e^t dt\right]= e^t \cos(t) + \sin(t)e^t + C\\ I = \int \cos(t)e^t dt =\frac12\left[e^t \cos(t) + \sin(t)e^t\right] + C$$
Now, to solve the original problem, you have to substitute back in $t=\ln(x)$.

#### mathworker

##### Active member
a slightly different approach after this step,
$$\displaystyle \int\cos{u}e^udu=\cos{u}e^u+\int\sin{u}e^udu$$
$$\displaystyle \int(\cos{u}-\sin{u})e^udu=\cos{u}e^u$$
$$\displaystyle \int\sqrt{2}\cos{(u+\frac{\pi}{4})}e^udu=\cos{u}e^u$$
there by,$$\displaystyle u+\frac{\pi}{4}=x$$
and you can proceed in traditional way

Last edited:

#### Chris L T521

##### Well-known member
Staff member
Hello Pedro,
I have not really spend time and check if this works but you should be able to use integrate by part with $$\displaystyle u=\cos(\ln x) <=> du = \frac{-\sin(\ln x)}{x} dx$$ and $$\displaystyle dv=dx <=>v=x$$ now when I think about this I think it will be infinity loop. Well I really don't have time to check this now as I have to go soon but I hope this is correctly as I remember from when I did one.

Edit: now when I read Opalg comment maybe my method is not valid.
Regards,
$$\displaystyle |\pi\rangle$$
Your method is actually valid - it will just continue looping through integrals of $\cos(\ln x)$ and $\sin(\ln x)$; however, you get back to $\cos(\ln x)$ after applying parts twice. It's at this point that you treat the integral as a variable and solve for it.

Meaning:

Let $u=\cos(\ln x)\implies \,du= -\dfrac{\sin(\ln x)}{x}\,dx$ and $\,dv=\,dx\implies v=x$, then
$\int \cos(\ln x)\,dx = x\cos(\ln x)+\int\sin(\ln x)\,dx$
Here, let $u=\sin(\ln x)\implies \,du = \dfrac{\cos(\ln x)}{x}\,dx$ and $\,dv=\,dx \implies v=x$. Thus,
$\int\sin(\ln x)\,dx = x\sin(\ln x) - \int\cos(\ln x)\,dx$
Putting the two pieces together yields
$\int \cos(\ln x)\,dx = x\cos(\ln x)+\left[x\sin(\ln x)-\int\cos(\ln x)\,dx\right]$
Thus,
$2\int\cos(\ln x)\,dx = x(\cos(\ln x)+\sin(\ln x))+C\implies \boxed{\displaystyle\int \cos(\ln x)\,dx = \tfrac{1}{2}x(\cos(\ln x) + \sin(\ln x))+C}$

I hope this clarifies things for the OP.