3

This integral was a misprint on my calculus exam but I was curious to see if there is a way to arrive at the complicated result Wolfram alpha gave:

$$I=\int x+x^{-1}-\ln(\cos x)dx=\\(\frac12-\frac i2)x^2+x\log(1+e^{2ix})+\ln(x)-x\ln(\cos x)-\frac12 i \operatorname{Li}_2(-e^{2ix})$$

My attempts consisted of trying to find a substitution that will yield an integral which if I add/subtract to $I$ will hopefully cancel some things out. Nevertheless I could not find any suitable u-sub and IBP doesn't seem to work here.

If anyone knows of a way to compute this I'd be greatful.

  • Welcome to Math.SE. $\log(\cos x)$ usually appers in definite integrals (with bounds $0$, $\pi/2$ or similar) but you're searching an antiderivative right? – Sine of the Time Jan 25 '25 at 15:44
  • Thanks! Yes I am searching for an antiderivative. Will the "substitution and then adding back to the original" method not work here? –  Jan 25 '25 at 15:46
  • 2
    $\log(\cos x)$ does not have an elementary antiderivative, so the usual tecniques you see in a calculus course will probably not work. See this – Sine of the Time Jan 25 '25 at 15:48

3 Answers3

3

Substitute $t=e^{-2ix}$ \begin{align}\int\ln(\cos x)dx& =\int i x -\ln 2 +\ln(1+e^{-2ix})\ dx\\ &=\frac i2x^2 - x\ln2 +\frac i2 \int \frac{\ln(1+t)}{t}dt \end{align} where $\int \frac{\ln(1+t)}{t}dt=-\text{Li}_2(-t)$.

Quanto
  • 120,125
1

Seeing all those terms containing $e$ and $i$ makes it only logical to write cosine with its exponential definition .

$$I= -\int \log\left(\cos\left(x\right)\right) \, \mathrm{d}x + \int x \, \mathrm{d}x + \int \frac{1}{x} \, \mathrm{d}x=-\underbrace{\int \log\left(\cos\left(x\right)\right) \, \mathrm{d}x}_{I_1}+\frac12x^2+\log(x)+C_1$$

Now focusing on $I_1$, $$I_1= \int \log\left(\frac{\mathrm{e}^{\mathrm{i}x} + \mathrm{e}^{-\mathrm{i}x}}{2}\right) \, \mathrm{d}x\stackrel{u=ix}{=} -\mathrm{i} \int \left(\log\left(\mathrm{e}^{u} + \mathrm{e}^{-u}\right) - \log\left(2\right)\right)\mathrm{d}u\\\stackrel{IBP}{=} -i\left(u \log\left(\mathrm{e}^{u} + \mathrm{e}^{-u}\right) - \underbrace{\int \frac{u \left(\mathrm{e}^{u} - \mathrm{e}^{-u}\right)}{\mathrm{e}^{u} + \mathrm{e}^{-u}} \, \mathrm{d}u}_{I_2} \right)$$ Then, $$I_2= \int \frac{u \left(\mathrm{e}^{2u} - 1\right)}{\mathrm{e}^{2u} + 1} \, \mathrm{d}u\stackrel{v = \mathrm{e}^{2u} + 1}{=} \frac{1}{4} \, \int \frac{\log\left(v - 1\right) \left(v - 2\right)}{\left(v - 1\right) v} \, \mathrm{d}v$$ Decomposing this into partial fractions we have $$\frac{\log\left(v - 1\right) \left(v - 2\right)}{\left(v - 1\right) v}= \left(\frac{2 \log\left(v - 1\right)}{v} - \frac{\log\left(v - 1\right)}{v - 1}\right) $$ Therefore ,

$$I_2= 2 \int \frac{\log\left(v - 1\right)}{v} \, \mathrm{d}v - \int \frac{\log\left(v - 1\right)}{v - 1} \, \mathrm{d}v $$

Here the first integrand can be written as $$\frac{\log(v-1)}{v}=\frac{\log(1-v)}{v}+\frac{\log(-1)}{v}$$

Thus, it is equal to $$\log\left(-1\right) \log\left(v\right) - \operatorname{Li}_{2}\left(v\right) + C_2$$

The second integrand is just $$\frac{\log^{2}\left(v - 1\right)}{2} + C_3$$

Substituting these back to $I$ we get :

$$I= -\frac{\mathrm{i} \log\left(-1\right) \log\left(\left|\mathrm{e}^{2\mathrm{i}x} + 1\right|\right)}{2} - x \log\left(\left|\mathrm{e}^{\mathrm{i}x} + \mathrm{e}^{-\mathrm{i}x}\right|\right) + \log\left(\left|x\right|\right) + \frac{\mathrm{i} \operatorname{Li}_{2}\left(\mathrm{e}^{2\mathrm{i}x} + 1\right)}{2} - \frac{\mathrm{i}x^{2}}{2} + \frac{x^{2}}{2} + \log\left(2\right) \, x + C\\= \frac{-\mathrm{i} \log\left(-1\right) \log\left(\cos\left(x\right) \left|\sin\left(x\right) - \mathrm{i} \cos\left(x\right)\right|\right) + \mathrm{i} \operatorname{Li}_{2}\left(2 \cos\left(x\right) \left(\mathrm{i} \sin\left(x\right) + \cos\left(x\right)\right)\right) + \left(1 - \mathrm{i}\right) x^{2}}{2} + \log\left(\left|x\right|\right) - x \log\left(2 \cos\left(x\right)\right) + \log\left(2\right) \, x + C\\=-2\mathrm{i} \left(\frac{2\mathrm{i}x \log\left(\mathrm{e}^{2\mathrm{i}x} + 1\right) + \operatorname{Li}_{2}\left(-\mathrm{e}^{2\mathrm{i}x}\right)}{4} + \frac{x^{2}}{2}\right) - \frac{2x \log\left(\mathrm{e}^{2\mathrm{i}x} + 1\right) - 3\mathrm{i}x^{2} - 2 \log\left(2\right) \, x}{2} + \log\left(x\right) + \frac{x^{2}}{2} + C\\=-\frac{\mathrm{i} \operatorname{Li}_{2}\left(-\mathrm{e}^{2\mathrm{i}x}\right) - 2 \log\left(x\right) + \left(-\mathrm{i} - 1\right) x^{2} - 2 \log\left(2\right) \, x}{2} + C\\=(\frac12-\frac i2)x^2+x\log(1+e^{2ix})+\ln(x)-x\ln(\cos x)-\frac12 i \operatorname{Li}_2(-e^{2ix})+C$$

Here $\log(\cdot)$ is referring to the natural logarithm and $\operatorname{L1}_2(\cdot)$ is the Dilogarithm.

Antony Theo.
  • 4,716
  • 1
    Thank you for this answer. I am still working through it. I only accepted because I dont have enough reputation to upvote. –  Jan 25 '25 at 16:20
-1

We first tackle the last integral.

\begin{aligned} \int \ln (\cos x) d x&=\int \ln \left(\frac{e^{x i}+e^{-x i}}{2}\right) d x \\ & =\int \ln \left(e^{x i}\left(1-e^{-2 x i}\right)\right)-\int \ln 2 d x \\ & =\int x i d x+\int \ln \left(1-e^{-2 x i}\right) d x-x \ln 2 \\ & =\frac{x^2}{2} i \quad-\frac{1}{2 i} \int \frac{\ln \left(1-e^{-2 x i}\right)}{e^{-2 x i}} d\left(e^{-2 x i}\right)-x \ln 2 \\ & =\frac{x^2}{2} +\frac{i}{2}\operatorname{ Li_2}\left(e^{-2 x i}\right)-x \ln 2+C_1 \end{aligned} Now we conclude that $$ \boxed{I=\frac{x^2}{2}+\ln |x|-\frac{x^2}{2} i-\frac{i}{2}\operatorname{ Li_ 2}\left(e^{-2 x i}\right)+x \ln 2+C} $$

Lai
  • 31,615