# Numerical Analysis: Why this function is giving Sage / WolframAlpha so much trouble to integrate?

I am trying to find the numerical value of $$\int_{-\pi}^\pi \sin(2\cos\theta)\cos(4\theta)\,d\theta$$.

The integrand looks like a nice, continuous function that is finite, bounded, differentiable, etc. Furthermore, I am just looking for a numerical value, not the exact antiderivative.

However, upon trying out first with WolframAlpha and Sage, none are able to give a satisfactory numerical value.

WolframAlpha ran out of computation time, and Sage gave an answer of order $10^{-17}$ with an error of order $10^{-15}$, i.e. the error is larger than the answer itself.

I am not an expert in numerical analysis, so I am puzzled at why this happened?

Any help will be greatly appreciated. Thanks.

Bonus: If anyone can tell me what is the numerical value (just accurate to 3 significant figures will be enough), I will upvote and accept your answer gratefully.

• $10^{-17}$ with an error of $10^{-15}$ suggests to me that it equals $0.$ – Doug M Sep 3 '16 at 4:08
• WolframAlpha swiftly returns and says zero. You must have made a typo. – user14972 Sep 3 '16 at 8:59
• W|A gives the answer for me just fine wolframalpha.com/input/… – Wojowu Sep 3 '16 at 9:25
• If you want a quick and dirty way to suppress Mathematica's "help I can't integrate this", just add a constant to the integrand and subtract it at the end. NIntegrate[Sin[2 Cos[t]] Cos[4 t] + 1, {t, -Pi, Pi}] - 2 Pi – Patrick Stevens Sep 3 '16 at 10:57
• I launched WolframAlpha with NIntegrate[Sin[2 Cos[t]] Cos[4 t], {t, -Pi, Pi}], the answer was shown almost immediately. The analytical version Integrate[Sin[2 Cos[t]] Cos[4 t], {t, -Pi, Pi}] is also quite fast to show the resulting zero. I do not know where the problem comes from - either bad internet connection, or a quick bugfix on server side (doubt that). – TZakrevskiy Sep 3 '16 at 19:34

The integrand $f(\theta):=\sin(2\cos\theta)\cos(4\theta)$ is an even function: $f(-\theta)=f(\theta)$. So the integral of $f$ over the interval $[-\pi,\pi]$ is double its value over $[0,\pi]$. However, check also that $$f\left(\frac\pi2+t\right)=-f\left(\frac\pi2-t\right),$$ i.e. the integrand has odd symmetry around the point $(\pi/2,0)$. Hence the integral equals zero.
The graph of the function makes it obvious: • It doesn't quite. We are all used to odd functions integrating to zero. But this one becomes odd only if moved by $\pi/2$. So at the first glance the graph makes it even stranger, not obvious. – Ruslan Sep 4 '16 at 12:17