TransWikia.com

Integration gives wrong result

Mathematica Asked by Rasoul-Ghadimi on September 2, 2021

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.

2 Answers

$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

Correct answer by Bob Hanlon on September 2, 2021

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.

Answered by Andreas on September 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP