# The integral $\int\ln(x)\cos(1+(\ln(x))^2)\,dx$

Help with a integral calculus please!?

The equation is

$$\int\ln(x)\cos(1+(\ln(x))^2)\,dx$$

My teacher told me, i have to use substitution? but i can't still solve it.

• Please check that my edit is correct. Mar 14 '16 at 10:38
• First did you try integration by parts or just type the steps with proper format so that someone might help Mar 14 '16 at 10:39
• Hint substitute $1+(ln(x))^2=u$ and then youll get $I=\int e^{(u-1)/2}.cosudu$ where cos can be written as $R(re^{iu})$ Mar 14 '16 at 10:50
• @ArchisWelankar, this can't be right. There should be a square root inside the exponential Aug 18 '16 at 14:34

First, consider the following integral:

$$I(t)=\int\sin(1+(t+\ln(x))^2)\ dx$$

By letting $x=e^u$ and $\sin(\theta)=\Im(e^{i\theta})$, we get

$$I(t)=\int e^u\sin(1+(t+u)^2)\ du=\Im\int e^{u+(1+(t+u)^2)i}\ du$$

This may then be solving using the error function,

$$\int e^{u+(1+(t+u)^2)i}\ du=\frac{-\sqrt{\pi i}e^{i+\frac{(2it+1)^2}{4i}}\operatorname{erf}\left(\frac{2iu+2it+1}2\sqrt i\right)}2$$

It then follows that

$$I'(t)=\frac d{dt}\int\sin(1+(t+\ln(x))^2)\ dx=\int2(t+\ln(x))\cos(1+(t+\ln(x))^2)\ dx\\I'(t)=\Im\frac d{dt}\frac{-\sqrt{\pi i}e^{i+\frac{(2it+1)^2}{4i}}\operatorname{erf}\left(\frac{2iu+2it+1}2\sqrt i\right)}2$$

Thus,

$$\frac12I'(0)=\int\ln(x)\cos(1+(\ln(x))^2)\ dx$$

Evaluating the derivative, one gets

\begin{align}\frac12I'(t)&=\Im\frac{-\sqrt{\pi i}}4\frac d{dt}e^{i+\frac{(2it+1)^2}{4i}}\operatorname{erf}\left(\frac{2iu+2it+1}2\sqrt i\right)\\&=\Im\frac{-\sqrt{\pi i}}4e^{i+\frac{(2it+1)^2}{4i}}\left[(2it+1)\operatorname{erf}\left(\frac{2iu+2it+1}2\sqrt i\right)+\frac{4i}{\sqrt\pi}e^{-\left(\frac{2iu+2it+1}2\sqrt i\right)^2}\right]\end{align}

Finally,

$$\int\ln(x)\cos(1+(\ln(x))^2)\ dx=\Im\frac{-\sqrt{\pi i}}4\left[e^{i+\frac1{4i}}\left[\operatorname{erf}\left(\frac{2iu+1}2\sqrt i\right)+\frac{4i}{\sqrt\pi}e^{-\left(\frac{2iu+1}2\sqrt i\right)^2}\right]\right]$$

Where $u=\ln(x)$.

• See here to simplify further. Feb 26 '17 at 14:01

First, substitute via $u=1+\ln^2(x)$ and use the complex exponential form of cosine to get \begin{align*} \int \ln(x) \cos(1+\ln^2(x)) \,dx &= \int \sqrt{u-1}\, \cos(u)\, \frac{\exp(\sqrt{u-1})}{2\sqrt{u-1}} \,du \\ &= \frac{1}{2} \int \cos(u)\,\exp(\sqrt{u-1}) \,du\\ &= \frac{1}{2} \int \frac{1}{2}[\exp(iu)+\exp(-iu)] \,\exp(\sqrt{u-1}) \,du \\ &= \frac{1}{4} \left[ {\int \exp(iu) \,\exp(\sqrt{u-1}) \,du} + \int \exp(-iu) \,\exp(\sqrt{u-1}) \,du \right]\\ &= \frac{1}{4} \left[ I_1 + I_2 \right] \end{align*} Let's deal with $I_1$ first. \begin{align*} I_1 &= {\int \exp(iu) \,\exp(\sqrt{u-1}) \,du}\\ &= \underbrace{-\exp(\sqrt{u-1}) i \exp(iu) }_{\gamma_1} - \int -i\exp(iu)\frac{\exp(\sqrt{u-1})}{2\sqrt{u-1}} \,du\\ &= -\gamma_1 + ie^i\int \exp(a^2i+a) \,da\\ &= -\gamma_1 + ie^i\int \exp\left( i\left[a-\frac{i}{2}\right]^2 +\frac{i}{4} \right) \,da\\ &= -\gamma_1 + i\exp\left(\frac{5i}{4}\right)\int \exp\left( \left[a\sqrt{i} - \frac{i^{3/2}}{2} \right]^2 \right) \,da\\ &= -\gamma_1 + \sqrt{i}\exp\left(\frac{5i}{4}\right)\int \exp\left( z^2 \right) \,da\\ &= -\gamma_1 + \frac{\sqrt{i\pi}}{2}\exp\left(\frac{5i}{4}\right)\,\text{erfi}(z) \end{align*} where the first step uses integration by parts, then the substitution $a=\sqrt{u-1}$ is used, followed by the substitution $z=a\sqrt{i} - i^{3/2}/2$. Recall that $\text{erfi}(z)=-i\,\text{erf}(iz)$.

Now for $I_2$, using a similar strategy. \begin{align*} I_2 &= {\int \exp(-iu) \,\exp(\sqrt{u-1}) \,du}\\ &= \underbrace{\exp(\sqrt{u-1}) i \exp(-iu)}_{\gamma_2} - \int i\exp(-iu)\frac{\exp(\sqrt{u-1})}{2\sqrt{u-1}} \,du\\ &= \gamma_2 - i\int \exp(-ia^2-i+a) \,da\\ &= \gamma_2 - ie^{-i}\int \exp\left( -i\left[a + \frac{i}{2}\right]^2 -\frac{i}{4} \right) \,da\\ &= \gamma_2 - i \exp\left( \frac{-5i}{4} \right) \int \exp\left( -\left[ a\sqrt{i} + \frac{i^{3/2}}{2} \right]^2 \right) \,da\\ &= \gamma_2 - \sqrt{i} \exp\left( \frac{-5i}{4} \right) \int \exp\left( -\zeta^2 \right) \,da\\ &= \gamma_2 - \frac{\sqrt{i\pi}}{2} \exp\left( \frac{-5i}{4} \right) \, \text{erf}(\zeta)\\ \end{align*} using the same subsitution with $a$ and with $\zeta = a\sqrt{i} + i^{3/2}/2$.

Ok, now let's simplify the terms without the error functions: \begin{align*} -\gamma_1 + \gamma_2 &= -\exp(\sqrt{u-1}) i \exp(iu) + \exp(\sqrt{u-1}) i \exp(-iu) \\ &= -\underbrace{\exp(\sqrt{u-1})}_{x}i[\underbrace{e^{iu} - e^{-iu}}_{2i\sin(u)}] \\ &= 2x\sin(1+\ln^2(x)) \\ \end{align*} where we used the complex exponential form of sine.

Next we need to be able to undo the substitutions: \begin{align*} z &= \sqrt{i} a - \frac{i^{3/2}}{2}\\ &= \sqrt{i} \sqrt{u-1} - \frac{i^{3/2}}{2}\\ &= \sqrt{i} \ln(x) - \frac{i^{3/2}}{2}\\ &= \frac{1}{2} \sqrt{i}\left[ 2\ln(x) - i \right]\\ \zeta &= \sqrt{i} a + \frac{i^{3/2}}{2}\\ &= \sqrt{i} \sqrt{u-1} + \frac{i^{3/2}}{2}\\ &= \sqrt{i} \ln(x) + \frac{i^{3/2}}{2}\\ &= \frac{1}{2} \sqrt{i}\left[ 2\ln(x) + i \right] \end{align*}

Now we can put it all together: \begin{align*} \int & \ln(x) \,\cos(1+\ln^2(x)) \,dx \\ &= \frac{1}{4} \left[ I_1 + I_2 \right]\\ &= \frac{1}{4} \left[ -\gamma_1 + \frac{\sqrt{i\pi}}{2}\exp\left(\frac{5i}{4}\right)\,\text{erfi}(z) + \gamma_2 - \frac{\sqrt{i\pi}}{2} \exp\left( \frac{-5i}{4} \right) \text{erf}(\zeta) \right]\\ &= \frac{1}{4} \left( -\gamma_1 + \gamma_2 + \frac{\sqrt{i\pi}}{2} \exp\left(\frac{-5i}{4}\right) \left[ \exp\left( \frac{5i}{2} \right) \text{erfi}(z) - \text{erf}(\zeta)\right] \right)\\ &= \frac{1}{4} \left( 2x\sin(1+\ln^2(x)) + \frac{\sqrt{i\pi}}{2} \exp\left(\frac{-5i}{4}\right) \left[ \exp\left( \frac{5i}{2} \right) \text{erfi}(z) - \text{erf}(\zeta)\right] \right)\\ &= \frac{1}{8} \left( 4x\sin(1+\ln^2(x)) + {\sqrt{i\pi}} e^{\frac{-5i}{4}} \left[ e^{\frac{5i}{2}} \text{erfi}\left(\frac{\sqrt{i}\left[ 2\ln(x) - i \right]}{2} \right) - \text{erf}\left(\frac{\sqrt{i}\left[ 2\ln(x) + i \right]}{2} \right)\right] \right) \end{align*}

A quick check in Mathematica gives:

f[x_] := Log[x] Cos[1 + (Log[x])^2]
FullSimplify[Integrate[f[x], x]]

1/8 ((-1)^(1/4) E^(-((5 I)/4))
Sqrt[\[Pi]] (-Erf[1/2 (-1)^(1/4) (I + 2 Log[x])] +
E^((5 I)/2) Erfi[1/2 (-1)^(1/4) (-I + 2 Log[x])]) +
4 x Sin[1 + Log[x]^2])


Which maybe should have been the whole answer...

• You seem to have solved the wrong problem, as it appears you solved $\int\ln(x)\cos(1+\color{red}2(\ln(x))^2)\ dx$. Feb 26 '17 at 14:08