# Approximating $\int \log\big[1+\sin^2(t)\big]\,dt$

On yesterday, a now closed question asked for a while how to compute the antiderivative $$I=\int \log\big[1+\sin^2(t)\big]\,dt$$ which, as given by a CAS, is just awful (see @Forester's comment and @Turing's answer). During the time the question was open, I tried on my side and gave up since being unable to find anything simpler.

Then, I tried to approximate the integrand since we just need a good representation of it for $$0 \leq t \leq \frac \pi 2$$ because of the symmetries and periodicity. What I am proposing is a polynomial function matching the function and its first and second derivative values at a minimum number of data points. For the time being, I chose $$t=0$$, $$t=\frac \pi 4$$ and $$t=\frac \pi 2$$. The final result is $$f(t)=\log\big[1+\sin^2(t)\big]\sim t^2+\frac 19 \sum_{n=3}^8 \frac{a_n}{\pi^n} t^n=g(t)$$ the $$a_n$$'s being $$\left( \begin{array}{ccc} n & a_n & \frac{a_n}{9\pi^n}\\ 3 & -768 \pi -217 \pi ^2-22608 \log (2)+18432 \log (3) & +0.087806356 \\ 4 & 7680 \pi +1940 \pi ^2+286416 \log (2)-221184 \log (3) & -1.360303642 \\ 5 & -27648 \pi -8500 \pi ^2-1501632 \log (2)+1105920 \log (3) & +1.225383826 \\ 6 & 43008 \pi +19568 \pi ^2+3960576 \log (2)-2801664 \log (3) & -0.512958585 \\ 7 & -24576 \pi -22720 \pi ^2-5170176 \log (2)+3538944 \log (3) & +0.102611702 \\ 8 & 10496 \pi ^2+2654208 \log (2)-1769472 \log (3) & -0.007207813 \end{array} \right)$$

About the norm $$\Phi=\int_0^{\frac \pi 2} \big[f(t)-g(t)\big]^2 \, dt=1.79 \times 10^{-8}$$ while the beautiful approximation $$\sin(t) \simeq \frac{16 (\pi -t) t}{5 \pi ^2-4 (\pi -t) t}\qquad \text{for} \qquad 0\leq t\leq\pi$$ would lead to $$\Phi=8.74 \times 10^{-7}$$ (almost $$50$$ times larger).

From this $$J(x)=\int_0^x \log\big[1+\sin^2(t)\big]\,dt\sim \frac 13 x^3+\frac 19 \sum_{n=3}^8 \frac{a_n}{(n+1)\,\pi^n} x^{n+1}$$

As a test $$J\left(\frac{\pi }{2}\right)=\frac{\pi }{181440}\left(432 (128 \log (3)-87 \log (2))-55 \pi ^2 \right)\approx 0.591383$$ to be compared to the exact value $$\pi \log\left(\frac{1+\sqrt{2}}{2}\right)\approx 0.591331$$ recalled by @projectilemotion in comments.

My questions

Without adding more terms, could it be possible to improve the approximation ? Would changes of base points could have a significant impact (if yes, how to optimize them ?)

Would, by chance, be known (in a simple form) the exact values of the integrals $$K_n=\int_{-\frac \pi n}^{\frac \pi n} \log\big[1+\sin^2(t)\big]\,dt$$ beside the case of $$n=2$$ ? If there were, I suppose that much better approximations could be done.

• Let $f(a)=\int_{-\pi/n}^{\pi/n}\log(a+\sin^2t)\,dt$. Then $\displaystyle f(a)=4\int\frac{\arctan(b\tan\frac\pi n)}{1-b^2}\,db$ where $b=\sqrt{1+1/a}$ and $K_n=f(1)$. Jan 10, 2021 at 11:01
• If we want some simple form of approximation, e.g., polynomial, here is one: \begin{align} \int_0^x \ln(1 + \sin^2 t) \mathrm{d} t &\approx 0.0007816865900x - 0.01981190300x^2 + 0.4408790493x^3\\ &\qquad - 0.2311179794x^4 + 0.03526708854x^5. \end{align} The largest absolute error is less than $0.00015$. Jan 10, 2021 at 13:04
• @TheSimpliFire. Thanks. I tried Feynman trick for both $\log(a+\sin^2t)$ and $\log(1+a\sin^2t)$ but I arrived to monsters I am unable to simplify. Any idea ? Cheers :-) Jan 11, 2021 at 3:00
• @RiverLi. Thanks for the effort ! However, I would like you check your regression since, as shown below, I have quite different results. I used $1000$ equally spaced values of $x$ between $0$ and $\frac \pi 2$ and obtained $(R^2=0.9999999897)$ the following results (see next comment). Maximum error $=0.00006$. Jan 16, 2021 at 4:22
• $$\begin{array}{clclclclc} \text{} & \text{Estimate} & \text{Standard Error} & \text{Confidence Interval} \\ a & +0.00240462 & 0.00003239 & \{+0.00234106,+0.00246818\} \\ b & -0.02970854 & 0.00017028 & \{-0.03004269,-0.02937439\} \\ c & +0.46029551 & 0.00030906 & \{+0.45968903,+0.46090198\} \\ d & -0.24616488 & 0.00023124 & \{-0.24661866,-0.24571110\} \\ e & +0.03927511 & 0.00006100 & \{+0.03915541,+0.03939482\} \\ \end{array}$$ Jan 16, 2021 at 4:23

A physicist's point of view. So i'm trying to keep things as simple as possible. (I'm using $$\ln x$$ rather than $$\log x$$).

The first step is to choose an approximate, simple analytical expression for $$\ln(1+y)$$ in $$y\in[0,1]:$$

$$\ln(1+y)\approx\frac{\ln 2}{131}y(20y^2-75y+186)$$

Now, set $$y=\sin^2t$$

$$\ln(1+\sin^2t)\approx\frac{\ln 2}{131}(131+35\cos^2t+20\cos^4t)\sin^2t$$

Next, integrate this expression with respect to $$t$$ over the interval $$[0, x]$$ $$x\in[0,\frac{\pi}{2}]$$ and denote the result $$I(x)$$

A closed-form expression can be obtained for $$I(x)$$ but it is a little bit messy. But for $$x=\frac{\pi}{2}$$ we obtain:

$$I\left(\frac{\pi }{2}\right)=\frac{569}{2096}\pi\ln 2$$

Absolute error from exact value is about $$0.0002$$

It is about an order of magnitude more inaccurate than Claude's result $$J\left(\frac{\pi }{2}\right)$$ but this is the price we have to pay for simplicity.

• Nice, although the closed form expression is not very simple. Jan 10, 2021 at 3:26
• You inspired me ! Thanks and $\to +1$ for sure. Cheers :-) Jan 10, 2021 at 10:30

After @Martin Gales's, I think that I had an idea.

Rewrite $$\log\big[1+\sin^2(t)\big]=\log\Bigg[\frac {1+ \frac{2 \sin ^2(t)}{5-\cos (2 t)}} {1- \frac{2 \sin ^2(t)}{5-\cos (2 t)}}\Bigg]$$

and use $$\log \left(\frac{1+a}{1-a}\right)=2 \sum_{n=0}^\infty \frac{a^{2n+1}}{2n+1}$$ to make $$\log\big[1+\sin^2(t)\big]=\sum_{n=0}^\infty \frac{4^{n+1}}{2n+1} \Bigg[\frac{ \sin ^2(t)}{5-\cos (2 t)}\Bigg]^{2n+1}$$ $$\int\log\big[1+\sin^2(t)\big]\,dt=\sum_{n=0}^\infty \frac{4^{n+1}}{2n+1} \int\Bigg[\frac{ \sin ^2(t)}{5-\cos (2 t)}\Bigg]^{2n+1}dt$$ All these integrals can be analytically computed (an example here) in terms of elementary trigonometric functions.

Computing $$S_p=\sum_{n=0}^p \frac{4^{n+1}}{2n+1} \int_0^{\frac \pi 2}\Bigg[\frac{ \sin ^2(t)}{5-\cos (2 t)}\Bigg]^{2n+1}dt$$ it looks better to write it as $$S_p=-\sqrt{\pi }\,\,\sum_{n=0}^p \frac{\Gamma \left(2 n+\frac{3}{2}\right)}{\Gamma (2 n+2)}\,B_{-\frac{1}{2}}\left(2 n+1,-2 n-\frac{1}{2}\right)$$ $$\left( \begin{array}{cc} p & S_p \\ 0 & 0.5764929933 \\ 1 & 0.5905254035 \\ 2 & 0.5912752808 \\ 3 & 0.5913264052 \\ 4 & 0.5913303391 \\ 5 & 0.5913306647 \\ 6 & 0.5913306929 \\ 7 & 0.5913306955 \\ 8 & 0.5913306957 \end{array} \right)$$ The last value in the table is $$S_8=\left(\frac{1593269}{765765}-\frac{2025528882598026950447}{436968810224560373760 \sqrt{6}}\right) \pi$$ (error= $$2.45\times 10^{-11}$$).

The next one $$S_9=\left(\frac{31037876}{14549535}-\frac{8543966267760579986943883}{179331999716159577 3911040 \sqrt{6}}\right) \pi$$ (error= $$2.35\times 10^{-12}$$).

This fast convergence is explained by the fact that, for large $$n$$ $$\frac{a_{n+1}}{a_n}=\frac{(4 n+3) (4 n+5)}{8 (n+1) (2 n+3)}\frac{B_{-\frac{1}{2}}\left(2 n+3,-2 n-\frac{5}{2}\right)}{B_{-\frac{1}{2}}\left(2 n+1,-2 n-\frac{1}{2}\right)}\to \sim \frac 19$$

Edit

If this could help

$$I_n=\frac{4^{n+1}}{2n+1} \int_0^{x}\Bigg[\frac{ \sin ^2(t)}{5-\cos (2 t)}\Bigg]^{2n+1}dt$$ can write $$I_n=\frac {z ^{4 n+3}}{4^n \,(2n+1)(4n+3)}F_1\left(2 n+\frac{3}{2};2 n+1,\frac{1}{2};2 n+\frac{5}{2};-\frac{z^2}{2},z^2\right)$$ where $$z=\sin(x)$$ and $$F_1(.)$$ is the Appell hypergeometric function of two variables.

Just for fun. Better than an approximate, the nice exact solution :

Of course this isn't from a normal man. Thanks to WolframAlpha.

• Yuck ! (beurk in French). Cheers :-) Mar 4, 2021 at 10:29