5
$\begingroup$

Already several pages of stack exchange dedicated to the integration problem in Mathematica. However, by reading them I did not find solution to my own integral. I know from NIntegrate and other criteria that the answer of following integral:

Integrate[
  (16 Cos[k]^2 Sin[th]^4 + Sin[2 (k)]^2 Sin[2 th]^2) / 
    ( 16 (-1 + Cos[k]^2 Cos[th]^2)^2), 
  {k, -π + alpha, π + alpha}, 
  PrincipalValue -> True]

gives the following wrong answer

-2 π Tan[th]^2

However, it gives different results by using NIntegrate?

Show @ 
  Table[
    Plot[{f[th, {0, 0.3, 0.5}[[i]]], -2 π Tan[ th]^2}, {th, -π, π}, 
      PlotStyle -> 
        {Directive[Dotted, {Black, Blue, Red}[[i]]], 
         Directive[Line, {Black, Blue, Red}[[i]]]}], 
    {i, 1, 3}]

where,

f[th_, alpha_] := NIntegrate[(16 Cos[k]^2 Sin[th]^4 + Sin[2 (k)]^2 Sin[2 th]^2)/(16 (-1 + Cos[k]^2 Cos[th]^2)^2), {k, -π + alpha, π + alpha}]

enter image description here

I would appreciate any comments or help.

$\endgroup$
4
  • 3
    $\begingroup$ Hello there! Please edit your question by providing more information so others can try to reproduce your results. Namely, what are alpha and f? What was the result you expected to get and how do you know the result you do get is wrong? $\endgroup$
    – Kiro
    Commented Jul 25, 2020 at 10:18
  • $\begingroup$ Plots Plot[(16 Cos[k]^2 Sin[th]^4 + Sin[2 (k)]^2 Sin[2 th]^2)/(16 (-1 + Cos[k]^2 Cos[th]^2)^2) /. th -> 1/2, {k, -\[Pi], \[Pi]}] and Plot[(16 Cos[k]^2 Sin[th]^4 + Sin[2 (k)]^2 Sin[2 th]^2)/(16 (-1 + Cos[k]^2 Cos[th]^2)^2) /. th -> -1, {k, -\[Pi], \[Pi]}] show no singularity. $\endgroup$
    – user64494
    Commented Jul 25, 2020 at 10:57
  • $\begingroup$ Plot Plot3D[(16 Cos[k]^2 Sin[th]^4 + Sin[2 (k)]^2 Sin[2 th]^2)/(16 (-1 + Cos[k]^2 Cos[th]^2)^2), {k, -\[Pi], \[Pi]}, {th, -Pi, Pi}]] shows no singularity too. Therefore, the PrincipalValue->True option is superfluous. $\endgroup$
    – user64494
    Commented Jul 25, 2020 at 16:34
  • $\begingroup$ @kiro, sorry for the late update. $\endgroup$ Commented Jul 27, 2020 at 2:40

2 Answers 2

6
$\begingroup$
$Version

(* "12.1.1 for Mac OS X x86 (64-bit) (June 19, 2020)" *)

Clear["Global`*"]

expr = (16 Cos[k]^2 Sin[th]^4 + 
     Sin[2 (k)]^2 Sin[2 th]^2)/(16 (-1 + Cos[k]^2 Cos[th]^2)^2);

int1[th_] = 
 Integrate[expr, {k, -π + alpha, π + alpha}, PrincipalValue -> True]

enter image description here

Adding some Assumptions,

int2[th_] = Assuming[{-Pi < th < Pi, 0 < alpha < 1},
  Integrate[expr, {k, -π + alpha, π + alpha}, PrincipalValue -> True]]

(* 2 π (-1 + Abs[Csc[th]]) Tan[th]^2 *)

The numeric integral is

int3[th_?NumericQ] := NIntegrate[expr, {k, -π + 1/10, π + 1/10}]

Visually comparing the integrals

Plot[Evaluate@{int1[th] // Normal, int2[th], int3[th]},
  {th, -Pi, Pi},
  PlotRange -> {-10, 4},
  PlotStyle -> {Automatic, Automatic, Dashed},
  PlotLegends -> Automatic] // Quiet

enter image description here

int2 is consistent with the numeric integration

$\endgroup$
3
  • $\begingroup$ So I think we have to use your approach to other problems. I mean putting integration in the assuming environment. $\endgroup$ Commented Jul 27, 2020 at 2:48
  • $\begingroup$ The problem is not with the assumptions, but as @Andreas says, that older versions "do not see the jumps of ArcTan at the poles of its argument", at k==-Pi/2 and Pi/2. A general workaround is to build the limit of the indefinite integral at these points (if function is not to complicated for Limit). See next comment. int[k_] = Integrate[integrand, k] . $\endgroup$
    – Akku14
    Commented Jul 27, 2020 at 6:59
  • $\begingroup$ (Limit[int[k], k -> Pi + alpha, Direction -> 1, Assumptions -> 0 <= alpha < 1] - Limit[int[k], k -> Pi/2, Direction -> -1] + Limit[int[k], k -> Pi/2, Direction -> 1] - Limit[int[k], k -> -Pi/2, Direction -> -1] + Limit[int[k], k -> -Pi/2, Direction -> 1] - Limit[int[k], k -> -Pi + alpha, Direction -> -1, Assumptions -> 0 <= alpha < 1]) // Simplify yields 2 \[Pi] (-1 + Sqrt[Csc[th]^2]) Tan[th]^2 . $\endgroup$
    – Akku14
    Commented Jul 27, 2020 at 7:00
7
$\begingroup$

First: the function can be simplified to

1/(1 + Csc[th]^2 Tan[k]^2).

Then you find the antiderivative

Integrate[1/(1 + Csc[th]^2 Tan[k]^2), k]
Sec[th] (ArcTan[Csc[th] Tan[k]] - k Sin[th]) Tan[th].

The problem with the integral is that it doesn't see the jumps of the ArcTan at the poles of its argument,so it is not continuous. A continuous antiderivative is:

Sec[th] (ArcTan[Csc[th] Tan[k]] - k Sin[th]) Tan[th] + π Sec[   th] Tan[th] Floor[k/π + 1/2]. 

This can be evaluated with your integration limits to:

2 π (Sec[th] - Tan[th]) Tan[th].

This agrees for π > th > 0 with Nintegrate numbers.

$\endgroup$
1
  • $\begingroup$ Solution for -Pi < th < Pi is 2 \[Pi] Sec[th] (Sign[Csc[th]] - Sin[th]) Tan[th] $\endgroup$
    – Akku14
    Commented Jul 28, 2020 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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