# 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.$ Commented Sep 3, 2016 at 4:08
• WolframAlpha swiftly returns and says zero. You must have made a typo.
– user14972
Commented Sep 3, 2016 at 8:59
• W|A gives the answer for me just fine wolframalpha.com/input/… Commented Sep 3, 2016 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 Commented Sep 3, 2016 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). Commented Sep 3, 2016 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.

• Nice. Triumph of human over machine. Commented Sep 3, 2016 at 4:19
• @yoyostein: A lot of triumphs of human over machine are merely examples of "The computer did what you asked it to, not what you wanted it to".
– user14972
Commented Sep 3, 2016 at 9:02

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. Commented Sep 4, 2016 at 12:17
• I meant the regions above and below the X axis are identical.
– user348749
Commented Sep 4, 2016 at 13:00