3

I am working on an integral on the following trigonometric functions

$$\int_{-\pi}^\pi \frac{\cos[(4m+2)x] \cos[(4m+1)x]}{\cos x}dx$$

where $m$ is positive integer. I am running the following code in mathematica

Assuming[Element[m, Integers] && (m > 0),
 Integrate[
  Cos[(4 m + 2) x] Cos[(4 m + 1) x]*1/Cos[x], {x, -π, π}]]

It gives me result of $\pi$. Since $m$ could be any positive number, I expect the integral should be $\pi$ if I replace $m$ with an integer before the integral. However, I got zero if I replace $m$ with number first.

LCarvalho
  • 9,233
  • 4
  • 40
  • 96
user1285419
  • 577
  • 1
  • 4
  • 12
  • @DanielLichtblau - I think there may be something more subtle going on here. I get an error in evaluating this integral – mikado Sep 26 '16 at 21:23
  • 1
    @Mikado Okay, I'll withdraw my close vote. There are some overlapping issues with the Assumptions/Assuming posts that have come up in past, nd also with the Assumptions->Element[something,Integers] posts. But I see now that this also involves a singularity that the assumptions will not appropriately handle, so there are subtleties. And of course a memory exception is not an anticipated outcome here. (I have not seen that result yet, because my evaluation has been running for minutes with no outcome yet). – Daniel Lichtblau Sep 26 '16 at 22:04

3 Answers3

1

The problem is very similar to that of [1] How to compute the integral of trigonometic function with multiple angle

Hence we don't repeat what we have discussed there but both answers should be read as complementary.

Let us focus here on the question of convergence of the integral.

The integrand is

g2[m_, x_] := Cos[(4 m + 2) x] Cos[(4 m + 1) x]*1/Cos[x];

The interesting values of x are those at which the Cos[x] becomes zero, i.e. at x = -π/2 and x = + π/2.

A series expansion about these points gives

Normal[Series[g2[m, x], {x, π/2, 0}]]

(* Out[184]= -Cos[2 m π]^2 - 4 m Cos[2 m π]^2 - (
 Cos[2 m π] Sin[2 m π])/(-(π/2) + x) + 2 Sin[2 m π]^2 + 
 4 m Sin[2 m π]^2 *)

For better visibility in LaTeX:

$$-\frac{\sin (2 \pi m) \cos (2 \pi m)}{x-\frac{\pi }{2}}+4 m \sin ^2(2 \pi m)+2 \sin ^2(2 \pi m)-4 m \cos ^2(2 \pi m)-\cos ^2(2 \pi m)$$

and

Normal[Series[g2[m, x], {x, -π/2, 0}]]

(* Out[185]= -Cos[2 m π]^2 - 4 m Cos[2 m π]^2 + (
 Cos[2 m π] Sin[2 m π])/(π/2 + x) + 2 Sin[2 m π]^2 + 
 4 m Sin[2 m π]^2 *)

LaTeX:

$$\frac{\sin (2 \pi m) \cos (2 \pi m)}{x+\frac{\pi }{2}}+4 m \sin ^2(2 \pi m)+2 \sin ^2(2 \pi m)-4 m \cos ^2(2 \pi m)-\cos ^2(2 \pi m)$$

These expressions remain finite if the numerator

num2 = Cos[2 m π] Sin[2 m π];

of the pole is zero.

This means

Simplify[num2]

(* Out[187]= 1/2 Sin[4 m π] *)

Reduce[% == 0, m] /. C[1] -> n

(* Out[188]= n ∈ Integers && (m == n/2 || m == (π + 2 n π)/(4 π)) *)

Which means that m must be of the form m = n/4 with n integer.

The integral of the OP is

f2[m_] := Integrate[g2[m, x], {x, -π, π}]

The first few values are

Table[{m/4, f2[m/4]}, {m, -5, 5}]

(* Out[195]= {{-(5/4), 0}, {-1, 2 π}, {-(3/4), 0}, {-(1/2), 2 π}, {-(1/4), 
  2 π}, {0, 0}, {1/4, 2 π}, {1/2, 0}, {3/4, 2 π}, {1, 0}, {5/4, 
  2 π}} *)

For values of m which are not integer multiples of 1/4 the integral is divergent.

For the OP [1] the convergence condition is m = n/2, n integer.

Dr. Wolfgang Hintze
  • 13,039
  • 17
  • 47
  • @ Dr. WolfangHintze : Something to adjust because of $\sin(2\pi m)=0$ for each integer $m.$ – user64494 Sep 23 '16 at 13:11
  • Integer multiples of quarters include halfs and integers. – Dr. Wolfgang Hintze Sep 23 '16 at 13:13
  • @ Dr. Wolfang Hintze : Sorry, don't understand it. Look at the formula under " For better visibility is LaTeX " in your answer. – user64494 Sep 23 '16 at 13:18
  • Also Assuming[Element[m, Integers] && (m > 0), Limit[Cos[(4 m + 2) x] Cos[(4 m + 1) x]*1/Cos[x], x -> Pi/2]] ouputs -1-4m. – user64494 Sep 23 '16 at 13:22
  • Thanks all. It makes sense to expand the integrand to figure the singularities. I just wonder why mathematica will directly given the answer $2\pi$ without considering the divergence. In what assumption mathematica makes to give that result. – user1285419 Sep 23 '16 at 20:42
  • "I just wonder why mathematica will directly given the answer 2π without considering the divergence. In what assumption mathematica makes to give that result" No assumptons is necessary any more because the value of m is inserted into the integrand before the integral is done, and there is not singularity any more in the integrand. – Dr. Wolfgang Hintze Sep 23 '16 at 22:27
  • @ Dr. Wolfgang Hintze: Mathematica 11 fails with it, outputting nothing. – user64494 Sep 26 '16 at 19:33
  • (at)user64494 what do you get if you calculate f2 above in version 11? You can add your result to my post, if you like. – Dr. Wolfgang Hintze Sep 27 '16 at 08:02
0

Solution #2: proof

Here's the missing proof that the integral

$$f(\text{m})=\int_{-\pi }^{\pi } \sec (x) \cos ((4 m+1) x) \cos ((4 m+2) x) \, dx$$

is zero for m = 0, 1, 2, ...

Following the idea of Yarchik in How to compute the integral of trigonometic function with multiple angle we observe that the integrand can be represented as the finite sum

s = -Sum[(-1)^n Cos[2 n (x)], {n, 1, 4 m + 1}];

Indeed

FullSimplify[s == Cos[x (4 m + 1)] Cos[x (4 m + 2)] Sec[x], m ∈ Integers]

(* True *)

Now the integral over s can be done for each summand separately which is

Integrate[Cos[2 n x], {x, -π, π}]
Simplify[%, {n ∈ Integers, n > 0}]

(* Out[288]= Sin[2 n π]/n *)

(* Out[289]= 0 *)

Now a finite sum of zeroes is zero. Hence the integral over s is zero and so is the original integral. QED.

Remark

Examples of finite sums over trigonometric functions of the type discussed here can be found in Gradshteyn/Ryshik 1.341

Dr. Wolfgang Hintze
  • 13,039
  • 17
  • 47
  • Gradshteyn&Ryzhik 1.341 does not include the formula suggested by Yarchik (see https://www.dropbox.com/s/5p6cpdetf9l3mtf/screen26.09.16.docx?dl=0 ) – user64494 Sep 26 '16 at 19:09
  • Yes, you are right, this example is not contained in GR. That's is why I provided it after some playing around with the sum in Mathematica. – Dr. Wolfgang Hintze Sep 27 '16 at 07:44
0

When I execute the code, I get an error. Have we found some sort of bug?

$Version
Assuming[Element[m, Integers] && (m > 0), 
 Integrate[
  Cos[(4 m + 2) x] Cos[(4 m + 1) x]*1/Cos[x], {x, -π, π}]]
(* "11.0.0 for Linux x86 (64-bit) (July 28, 2016)" *)
(* Throw::sysexc: Uncaught SystemException returned to top level. Can be caught with Catch[…, _SystemException]. *)
(* SystemException["MemoryAllocationFailure"] *)
mikado
  • 16,741
  • 2
  • 20
  • 54