5
$\begingroup$

I got the following integral from a book and it is said that the integral should be zero within the domain $[-\pi, \pi]$

$$ \int_{-\pi}^{\pi}\sec(x)\cos[(m+1)(x+\pi/2)]\sin[m(x+\pi/2)]dx $$ where $m$ is positive integer.

however, when I plug in the above integral into mathematica and limit the $m$ to be integer, it takes the matehamtica forever to run and end up with failure to get the result.

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

Any idea to work out the integral by mathematica is welcomed.

$\endgroup$
  • $\begingroup$ The integral is zero for integer m>=0 and m = - 2 pi for integer m < 0. Even the integral taken between 0 and Pi is zero for integer m >=0 and - pi for integer m <0. $\endgroup$ – Dr. Wolfgang Hintze Sep 23 '16 at 9:55
  • $\begingroup$ As I stated in the question, m is positive integer instead of real number. I am able to get the zero result by plugging in specific m but I am looking for a way to prove that any positive integer will give zero as well. $\endgroup$ – user1285419 Sep 23 '16 at 16:19
6
$\begingroup$

EDIT #2

The integral of the OP belongs to a broader class of divergent integrals which, first of all, must be given sense by defining how to circumvent the singularities.

Such divergent integrals are surprisingly frequent in integral tables such as Gradshteyn/Ryshik.

In our problem we compare two approaches

1) restrict the parameter m to appropriate "eigenvalues"
2) take the pricipal value

ad 1 "eigenvalues"

We have already shown here that the integral in question is convergent only if m is an integer multiple of 1/2.

In this case we can use the periodicity of the integrand to write the integral as

fye = 1 /2 Integrate[(Sin[y (2 m + 1)]/Sin[y] - 1), {y, -\[Pi]/
     2, \[Pi]/2}];

The result is

(* fye = 1/2 (-\[Pi] + 
   1/2 (HarmonicNumber[-1 - m/2] - HarmonicNumber[-(1/2) - m/2] - 
      HarmonicNumber[1/2 (-1 + m)] + HarmonicNumber[m/2]) Sin[
     m \[Pi]]) *)

For integer m this gives (notice that we have to take the Limit)

Table[Limit[fye, m -> i], {i, -4, 4}]

(* Out[169]= {-\[Pi], -\[Pi], -\[Pi], -\[Pi], 0, 0, 0, 0, 0} *)

ad 2 pricipal value

For general real m we can define the integral by the PrincipalValue.

fyp = 1/2 Integrate[(Sin[y (2 m + 1)]/Sin[ y] - 1), {y, \[Pi]/2, 
    3 \[Pi]/2}, PrincipalValue -> True]

(* 1/2 (-\[Pi] + 
   1/(4 m)E^(-3 I m \[Pi]) (-1 + E^(2 I m \[Pi])) (-2 I - 
      2 I E^(4 I m \[Pi]) + 2 E^(I m \[Pi]) m \[Pi] + 
      2 E^(3 I m \[Pi]) m \[Pi] - I m \[Pi] Cot[(m \[Pi])/2] + 
      I m PolyGamma[0, 1/2 - m/2] - 
      I (1 + E^(4 I m \[Pi])) m PolyGamma[0, m/2] + 
      I E^(4 I m \[Pi]) m PolyGamma[0, (1 + m)/2])) *)

In the limit of integer m we find

Table[Limit[fyp, m -> i], {i, -4, 4}]

(* Out[166]= {-\[Pi], -\[Pi], -\[Pi], -\[Pi], 0, 0, 0, 0, 0} *)

Comparison

We compare the functions of m obtained by the two approaches in a plot

Plot[{fye, fyp}, {m, -5, 5}, 
 PlotLabel -> 
  "Comparison of definitions of the divergent integral\n\
\!\(\*FormBox[\(fyp\\\  = \*FractionBox[\(1\), \(2\)]\\\ \
\(\*SubsuperscriptBox[\(\[Integral]\), FractionBox[\(\[Pi]\), \(2\)], \
FractionBox[\(3\\\ \[Pi]\), \(2\)]]\((\*FractionBox[\(sin(\((2\\\ m + \
1)\)\\\ y)\), \(sin(y)\)] - 1)\) \[DifferentialD]y\)\),
TraditionalForm]\)\nPrincipalValue (yellow) and eigenvalue (blue)\n\!\
\(\*FormBox[\(fye\\\  = \\\ \*FractionBox[\(1\), \(2\)]\\\ \
\(\*SubsuperscriptBox[\(\[Integral]\), \(-\*FractionBox[\(\[Pi]\), \
\(2\)]\), FractionBox[\(\[Pi]\), \(2\)]]\((\*FractionBox[\(sin(\((2\\\
\ m + 1)\)\\\ y)\), \(sin(y)\)] - 1)\) \[DifferentialD]y\)\),
TraditionalForm]\)\nResults coincide for integer values of m\n", 
 Epilog -> {{PointSize[Large], (Point[{#, 0}] &) /@ 
     Range[0, 6]}, {PointSize[
     Large], (Point[{#, -\[Pi]}] &) /@ -Range[1, 5]}}]     

enter image description here

This shows that the two methods lead to different "interpolating functions" which coincide at integer points but are different at half integer points.

Restriction to domain Integers

Unfortunately, restricting m to the domain of Integers in the "interpolating functions" leads to wrong results in both cases:

Simplify[fye, {m \[Element] Integers, m > 0}]

(* Out[178]= -(\[Pi]/2) *)

Simplify[fyp, {m \[Element] Integers, m > 0}]

(* Out[179]= 1/4 (-1 + (-1)^m) \[Pi] *)

EDIT #1

I understand that you did not consider my answer as satisfactory because it relied on calculating the integral for some typical explicit integer constants m rather than finding an expression for the whole class of positive integer values of m which then proves to be zero for those m.

Although I don't have the answer of this type the following ideas might be interesting as they point to a difficulty or weakness (or even a bug) in Mathematica.

Changing the integration variable to

x -> y - \[Pi]/2;

the integral becomes

fy := Integrate[Cos[(m + 1) y] Sin[m y]/Sin[y], {y, -\[Pi]/2, 3 \[Pi]/2}]

Now replacing the trig function by complex exponentials we find the identity

FullSimplify[
 Cos[(m + 1) y] Sin[m y]/Sin[y] == 1/2 (Sin[y (2 m + 1)]/Sin[y] - 1)]

(* Out[136]= True *)

which leads to a more symmetric form of the integrand.

Furthermore, the integrand is periodic for integer m:

FullSimplify[
 Sin[y (2 m + 1)]/
  Sin[y] == (Sin[y (2 m + 1)]/Sin[y] /. y -> y + \[Pi]), 
 m \[Element] Integers]

(* Out[137]= True *)

so that, for integer m, the integral over the range {-\[Pi]/2,\[Pi]/2} is the same as that over the range {\[Pi]/2,3 \[Pi]/2}, and hence the integral fy becomes

fy1 = Integrate[(Sin[y (2 m + 1)]/Sin[y] - 1), {y, -\[Pi]/2, \[Pi]/2}]

(* Out[143]= -\[Pi] + 1/
  2 (HarmonicNumber[-1 - m/2] - HarmonicNumber[-(1/2) - m/2] - 
    HarmonicNumber[1/2 (-1 + m)] + HarmonicNumber[m/2]) Sin[m \[Pi]] *)

in Latex:

$$fy1 = \frac{1}{2} \left(H_{\frac{m}{2}}+H_{-\frac{m}{2}-1}-H_{-\frac{m}{2}-\frac{1}{2}}-H_{\frac{m-1}{2}}\right) \sin (\pi m)-\pi$$

The graph is

Plot[fy1, {m, -5, 10}]

enter image description here

Unfortunately, simplifying fy1 to positive integer m Mathematica gives a wrong result:

Simplify[fy1, {m \[Element] Integers, m >= 0}]

(* Out[145]= -\[Pi] *)

The correct result is zero.

The reason is that Mathematica does not notice that the zero in Sin[m \[Pi]] is cancelled by the infinity in HarmonicNumber for negative integers. Here is an example to illustrate this weakness (or bug) of Mathematica:

Limit[HarmonicNumber[-k] Sin[\[Pi] k], k -> 1]

(* Out[156]= -\[Pi] *) correct

Simplify[HarmonicNumber[-k] Sin[\[Pi] k], k \[Element] Integers]

(* Out[147]= 0 *) wrong

But in the limit to an integer we find again

Table[Limit[fy1, m -> k], {k, -4, 4}]

(* Out[201]= {-2 \[Pi], -2 \[Pi], -2 \[Pi], -2 \[Pi], 0, 0, 0, 0, 0} *)

A similar example of the weakness, with more familiar functions, is:

Simplify[Gamma[-n] Sin[n \[Pi]], {n \[Element] Integers, n > 0}]

During evaluation of In[203]:= Simplify::infd: Expression Gamma[-n] simplified to ComplexInfinity. >>

During evaluation of In[203]:= Simplify::infd: Expression Gamma[-n] Sin[n [Pi]] simplified to Indeterminate. >>

(* Out[203]= Indeterminate *)

Limit[Gamma[-n] Sin[n \[Pi]], n -> #] & /@ {1, 2, 3, 4}

(* Out[204]= {-\[Pi], -(\[Pi]/2), -(\[Pi]/6), -(\[Pi]/24)} *)

Final remark: there should be some much simpler way - using symmetry arguments - to prove the correct result. But, alas, I haven't found it yet.

My original answer

Things become much simpler if you study the integral for explicit integer numbers m, rather than imposing the variable type Integers:

Let

f[m_] := Integrate[
  Sec[x] Cos[(m + 1) (x + π/2)] Sin[m (x + π/2)], {x, -π, π}]

Then

Table[{m, f[m]}, {m, -5, 5}]

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

And let

f1[m_] := Integrate[
  Sec[x] Cos[(m + 1) (x + π/2)] Sin[m (x + π/2)], {x, 0, π}]

Then

Table[{m, f1[m]}, {m, -5, 5}]

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

These results verify my comment.

It can easily be seen that due to the factor Sec[x] the integral is convergent only for integer and half integer m.

C.f. your other OP Integral of trigonometric function gives different answer

$\endgroup$
  • $\begingroup$ This does not answer the question. $\endgroup$ – user64494 Sep 23 '16 at 13:25
  • $\begingroup$ The question was: "Any idea to work out the integral by mathematica is welcomed." I have shown that Matematica - if applied appropriately - worked out the integral, and it turned out to be zero. BTW: forcing Mathematica to do the task in a prescribed specifiy way can lead to failure. $\endgroup$ – Dr. Wolfgang Hintze Sep 23 '16 at 13:48
  • $\begingroup$ Thanks for the code. But m is positive integer and I am looking for a way to provide that any m will make the integral zero instead of a specific m. $\endgroup$ – user1285419 Sep 23 '16 at 16:16
  • $\begingroup$ Thanks Dr. Wolfgang Hintze. I learn something from the answer. But I have some quick questions. First, in the recent edit, you state "We have already shown here that the integral in question is convergent only if m is an integer multiple of 1/2", why 1/2 instead of integers? You mention "eigenvalues", is that related to something for the eigenvalue problem? It is confusing since I don't see any thing about solving the eigenvalue problem but just the simple integral. Also, what's the principal value really does there? $\endgroup$ – user1285419 Sep 28 '16 at 3:33
  • $\begingroup$ @user64494 As to your quick questions (1) you can verify that the integral is convergent not only for integer values of m but also for half integer values. Notice that the integers are contained in the set of "multiples of 1/2". (2) I used the term "eigenvalue" here just because of the striking similarity to conventional eigenwert problems such as in Quantum mechanics. There you also have some quantity (the integral of the absolute value of the wave function) getting infinite unless the parameter (energy) has specific values. (3) please see my extensive answer to your related question. $\endgroup$ – Dr. Wolfgang Hintze Sep 28 '16 at 12:12
3
$\begingroup$

First, let us observe that your function can be written in the finite sum form:

f=Sum[(-1)^n Cos[2 n x], {n, m}]

Easy to check that both expressions are equivalent

Simplify[Sum[(-1)^n Cos[2 n x], {n, m}] - 
  Sec[x] Cos[(m + 1) (x + Pi/2)] Sin[m (x + Pi/2)]]
(*0*)

Now exchange the order of summation and integration (mathematically justified because the sum is finite):

Sum[Integrate[(-1)^n Cos[2 n x], {x, -Pi, Pi}], {n, m}]
(*0*)
$\endgroup$
  • $\begingroup$ @ yarchik : Could you explain how you came to the finite sum form? Thanks in advance. $\endgroup$ – user64494 Sep 24 '16 at 12:46
  • $\begingroup$ (at)yarchik Excellent ! Exactly to the point. $\endgroup$ – Dr. Wolfgang Hintze Sep 24 '16 at 12:52
  • $\begingroup$ @user64494 Cos and Sin of multiple angles in numerator and a single trigonometric function in denominator suggests the finite sum form. I was not sure about the (-1)^n pre-factor though. Had to play around little bit. $\endgroup$ – yarchik Sep 24 '16 at 13:05
  • $\begingroup$ That's pretty cool but I just don't know how to write the integrand in terms of the form you gave. It's cool though. $\endgroup$ – user1285419 Sep 28 '16 at 3:36
1
$\begingroup$

Too long for a comment:

Integrate[Sec[x]*FullSimplify[Cos[Expand[(m + 1)*(x + Pi/2)]]*Sin[Expand[m*(x + Pi/2)]], Assumptions -> m \[Element] Integers], {x, -Pi, Pi}, Assumptions -> m \[Element] Integers && m > 0]



 \[Pi] (-1 + (-1)^m (-Sqrt[\[Pi]] MeijerG[{{1}, {-2 m, 2 (1 + m)}}, {{1, 1}, {1/2}}, 1/2] + I Sin[m \[Pi]]))
$\endgroup$
  • $\begingroup$ And what happes if you insert m->1 in your final result? $\endgroup$ – Dr. Wolfgang Hintze Sep 23 '16 at 14:04
  • 1
    $\begingroup$ @user64494 You have Sec[x] twice in your code. Removing it solves the issue mentioned by Wolfgang. The last FullSimplify is perhaps not needed (actually, it's just doing a long computation, and I aborted it before the end). $\endgroup$ – user31159 Sep 23 '16 at 14:18
  • $\begingroup$ @ Xavier : Thank you. Edited. $\endgroup$ – user64494 Sep 23 '16 at 14:23
  • $\begingroup$ Thanks. I copy the code but it doesn't run in mathematica. Some mismatching bracket. $\endgroup$ – user1285419 Sep 23 '16 at 16:21
  • $\begingroup$ @user1285419: Thank you. Fixed. $\endgroup$ – user64494 Sep 23 '16 at 16:33
0
$\begingroup$
int[x_] = Integrate[Sec[x] Cos[(m + 1) (x + π/2)] Sin[m (x + π/2)], x]
ans[m_] = Simplify[int[Pi] - int[-Pi]]

1/8 I E^(-3 I m π) (8 I E^( 3 I m π) π + (-1 + E^(4 I m π)) PolyGamma[0, 1/2 - m/2] + (E^(2 I m π) - E^(6 I m π)) PolyGamma[0, 1 + m/2] + PolyGamma[0, -(m/2)] - E^(4 I m π) PolyGamma[0, -(m/2)] - E^(2 I m π) PolyGamma[0, (1 + m)/2] + E^(6 I m π) PolyGamma[0, (1 + m)/2])

Plot[Evaluate[{Re[ans[m]], Im[ans[m]]}], {m, 0., 3}]

enter image description here

$\endgroup$
  • $\begingroup$ Something to adjust because ans = Simplify[int[Pi] - int[-Pi], Assumptions -> m [Element] Integers && m > 0] produces $-\pi$. $\endgroup$ – user64494 Sep 24 '16 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.