# Two different Integration results for the same integrand in Mathematica

I want to calculate $$\int_0^\pi d\theta\sin\theta\, \left(\sqrt{1 \over 1-\left(1-(1-\gamma^2)^4\right)\cos^2\theta} - 1\right)^q$$.

For the simplest case of $$q=1$$ we have

q = 1;
A1 = Assuming[gamma ∈ Reals && 0 <= gamma < 1,
Integrate[Sin[theta] (Sqrt[1/(1 - (1 - (1 - gamma^2)^4) Cos[theta]^2)] - 1) , theta]
];

B1 = Limit[A1, theta -> Pi, Direction -> "FromBelow"]  - Limit[A1, theta -> 0, Direction -> "FromAbove"];
B1 /. gamma -> 0.1


gives

0.0133732 + 0. I


Now, let's define $$a = \left(1-(1-\gamma^2)^4\right)$$, put it in the integrand and after integration put the value of $$a$$ back to the final expression in terms of $$gamma$$:

q = 1;
A2 = Assuming[a ∈ Reals && 0 <= a < 1,
Integrate[Sin[theta] (Sqrt[1/(1 - a Cos[theta]^2)] - 1), theta]
] /. a-> (1 - (1 - gamma^2)^4);

B2 = Limit[A2, theta -> Pi, Direction -> "FromBelow"]  - Limit[A2, theta -> 0, Direction -> "FromAbove"]
B2 /. gamma -> 0.1


which gives

-31.6393 + 0. I


The two results are totally different symbolically and numerically, while the integrand is the same.

A1 and A2 have expressions containing logarithms meaning you run the risk of 'over-integrating' around the non-principal values of the logarithm - remember that $$\log(z) = \log(|z|)+i (\arg(z)+2k\pi)$$. If you add some additional assumptions theta >= 0 && theta \[Element] Reals to your A2 you get a matching answer with zero imaginary part:


A2 = Assuming[
a \[Element] Reals && 0 <= a < 1 && theta >= 0 &&
theta \[Element] Reals,
Integrate[Sin[theta] (Sqrt[1/(1 - a Cos[theta]^2)] - 1),
theta]] /. a -> (1 - (1 - gamma^2)^4);

B2 = Limit[A2, theta -> Pi, Direction -> "FromBelow"] -
Limit[A2, theta -> 0, Direction -> "FromAbove"]
B2 /. gamma -> 0.1
(*0.0133732*)

• Amazing! loved it!! Thanks a lot! Do you have a reference to suggest to me to read on this issue? I have no background to understand "'over-integrating' around the non-principal values of the logarithm" and I am interested to learn. Thank you again for your help! – Fluid May 23 at 20:59
• Take a look at en.wikipedia.org/wiki/Complex_logarithm. Are you familiar with complex numbers? Basically $e^{i k}$ goes round and around a unit circle in the complex plane. This means if you take the inverse (the logarithm) there's the usual answer in the real numbers called the principal value, but also many more complex answers. – flinty May 23 at 21:09
• Try this to get a feel for it: Manipulate[ListPlot[ {{Re[Exp[I \[Pi] k]], Im[Exp[I \[Pi] k]]}}, PlotRange -> {{-1.25, 1.25}, {-1.25, 1.25}}, AspectRatio -> 1], {k, 0, 2 \[Pi]}] – flinty May 23 at 21:09