Integrating $\int_{-\frac{\pi}{4}}^{\frac{\pi}{4}} \frac{\log\left( x^2 + 2 x \sin(\theta) + 1 \right)}{x + 2 \sin(\theta)} d\theta$

As I wrote in a comment, a CAS was able to find the antiderivative (the resulting formula is a few pages long !).

The only thing I was able to do is to expand the integrand as a Taylor series built at $t=0$ and then to integrate between the given bounds. Using the expansion to $O(t^{5})$ the result is $$3840 x^5 \left(x^2+1\right)^4\,I(x)=2 \left(960 \pi x^4+80 \pi ^3 x^2-\pi ^5 \left(x^2-12\right)\right) \left(x^2+1\right)^4 \log \left(x^2+1\right)+\pi ^3 x^2 \left(\pi ^2 \left(3 x^8-42 x^6-97 x^4-82 x^2-24\right)-80 \left(3 x^2+2\right) \left(x^3+x\right)^2\right)$$

Using $x=10^k$ and the above formula, we can compare with the numerical integration. Below are some results for ten significant figures. $$\left( \begin{array}{ccc} k & \text{approximation} & \text{integration} & \color{blue} {\text{Maxim's asymptotics}}\\ 1 & 0.7285409898 & 0.7285572863 & \color{blue} {0.7284940770}\\ 2 & 0.1446859930 & 0.1446860624 & \color{blue} {0.1446860611}\\ 3 & 0.02170136876 & 0.02170136887 &\color{blue} { 0.02170136887}\\ 4 & 0.002893513786 & 0.002893513786 & \color{blue} {0.002893513786}\\ 5 & 0.0003616892206 & 0.0003616892206 & \color{blue} {0.0003616892206}\\ 6 & 0.00004340270647 & 0.00004340270647 & \color{blue} {0.00004340270647} \end{array} \right)$$ Using the result and expanding again as a Taylor series for infinitely large values of $x$ $$I(x)=\pi \frac {\log(x)} x+O\left(\frac{\log(x)}{x^3}\right)$$

Edit

For the evaluation fo the integral, it could be simpler to build a $[1,1]$ Padé approximant at $t=0$. This will give for the integrand $$\frac{a +b\, t}{1+c\, t}=\frac b c+\frac{a-\frac b c}{1+c\,t}$$ (easy to integrate) where $$a=\frac{\log \left(x^2+1\right)}{x}$$ $$b=\frac{\left(x^2+2\right) \log \left(x^2+1\right)-2 x^2}{\left(x^2+1\right) \left(\left(x^2+1\right) \log \left(x^2+1\right)-x^2\right)}$$ $$c=\frac{2 \left(x^2+1\right)^2 \log \left(x^2+1\right)-x^2 \left(3 x^2+2\right)}{x \left(x^2+1\right) \left(\left(x^2+1\right) \log \left(x^2+1\right)-x^2\right)}$$ This would give $$\left( \begin{array}{ccc} k & \text{approximation} & \text{integration} \\ 1 & 0.7290369069 & 0.7285572863 \\ 2 & 0.1446872219 & 0.1446860624 \\ 3 & 0.02170137072 & 0.02170136887 \\ 4 & 0.002893513788 & 0.002893513786 \\ 5 & 0.0003616892207 & 0.0003616892206 \\ 6 & 0.00004340270647 & 0.00004340270647 \end{array} \right)$$

Update

Concerning the initial Taylor expansion, the problem is a little simpler considering $$\frac{\log (a+2 b \sin (t))}{b+2 \sin (t)}=\sum_{n=0}^4 c_i \, t^i + O\left(t^5\right)$$ where $a=x^2+1$ and $b=x$. This leads to $$c_0=\frac{\log (a)}{b}\qquad c_1=\frac{2 \left(b^2-a \log (a)\right)}{a b^2}$$ $$c_2=\frac{4 a^2 \log (a)-2 b^2\left(2 a +b^2\right)}{a^2 b^3}$$ $$c_3=\frac{a^3 \left(b^2-24\right) \log (a)+24 a^2 b^2-(a-12) a b^4+8 b^6}{3 a^3 b^4}$$ $$c_4=\frac{-4 a^4 \left(b^2-12\right) \log (a)-48 a^3 b^2+4 (a-6) a^2 b^4+2 (a-8) a b^6-12 b^8}{3 a^4 b^5}$$ Now $$\int_{-\frac \pi 4}^{\frac \pi 4} \frac{\log (a+2 b \sin (t))}{b+2 \sin (t)}\,dt\approx\frac{\pi}{2} c_0+\frac{\pi ^3}{96} c_2+\frac{\pi ^5 }{2560}c_4$$ Going to asymptotics $$I(x)=\pi\frac{ \log (x)}{x}\left(1+\frac{\pi ^2 \left(80-\pi ^2\right)}{960\, x^2} +\cdots\right)$$

Update

After Maxim's answer, I added in blue the value obtained for the integral using jis/her asymptotics. Much better than mine.


If you make the standard substitution $\theta = 2 \arctan u$, the integrand becomes $$\frac {\ln \frac {P(u)} {Q(u)}} {R(u)},$$ where $P, Q, R$ are quadratic polynomials. Factoring the polynomials and formally expanding the logarithm reduces the indefinite integral to a sum of integrals of the form $$\int \frac {\ln u} {u + a} du = \ln u \ln \left( 1 + \frac u a \right) + \operatorname{Li}_2 \left( - \frac u a \right).$$ With the natural choice of the factors, the antiderivative will be continuous in $u$ for large positive $x$, yielding a closed form for the definite integral.

To obtain the asymptotic, you can simply expand the integrand around $x = \infty$ and integrate term by term: $$\frac {\ln (x^2 + 2 x \sin \theta + 1)} {x + 2 \sin \theta} = \\ \frac {2 \ln x} x - \frac {4 \ln x \sin t - 2 \sin t } {x^2} + \frac {8 \ln x \sin^2 t + \cos 2 t - 4 \sin^2 t} {x^3} + o(x^{-3}), \\ I(x) = \frac {\pi \ln x} x + \frac {2 (\pi - 2) \ln x - \pi + 3} {x^3} + o(x^{-3}).$$


For $x$ sufficiently large, and putting all in the form

$$2\int_{-\pi/4}^{\pi/4} \frac{\log(x)}{x}\cdot \frac{\textrm{d}\theta}{1+2\sin(\theta)/x}+\int_{-\pi/4}^{\pi/4} \frac{\log\left(1 + 1/x (2\sin(\theta) + 1/x) \right)}{x }\cdot \frac{\textrm{d}\theta}{1+2\sin(\theta)/x} $$ combined with the power series of $\log(1+x)$ and $\displaystyle \frac{1}{1+x}$, and integrating termwise, we arrive, for example, at the asymptotical behaviour

$$I(x)\approx\pi\frac{\log(x)}{x}+\frac{2(\pi-2)\log(x)+3-\pi}{x^3}+\frac{12(3\pi-8)\log(x)-21\pi+64}{6x^5}.$$