Consider this integral: $$ \int_0^\pi d\theta \sin\theta\, {1 \over \gamma^q}\left((1-\gamma^2)^2\sqrt{1 \over 1-\left(1-(1-\gamma^2)^4\right)\cos^2\theta} - 1\right)^q $$ for $0\leq \gamma < 1$. The integrand is real, but the result of the integration is a complex number.
Here is the code:
q = 14;
A1 = Assuming[
a \[Element] Reals && 0 <= a < 1 && b \[Element] Reals &&
0 <= b < 1 && theta >= 0 && theta \[Element] Reals,
Integrate[Sin[theta] (b Sqrt[1/(1 - a Cos[theta]^2)] - 1)^q,
theta]];
B1 = Assuming[
a \[Element] Reals && 0 <= a < 1 && b \[Element] Reals &&
0 <= b < 1,
Limit[A1, theta -> Pi, Direction -> "FromBelow"] -
Limit[A1, theta -> 0, Direction -> "FromAbove"]
];
C1 = 1/gamma^q B1 /. {a -> (1 - (1 - gamma^2)^4),
b -> (1 - gamma^2)^2};
Print["q = ", q, " --> C1/.gamma\[Rule] 0.1 = ", C1 /. gamma -> 0.1];
Print["q = ", q, " --> C1/.gamma\[Rule] 0.5 = ", C1 /. gamma -> 0.5];
Print["q = ", q, " --> C1/.gamma\[Rule] 0.9 = ", C1 /. gamma -> 0.9];
and the results are
q = 14 --> C1/.gamma-> 0.1 = 454.747 +0.355271 I
q = 14 --> C1/.gamma-> 0.5 = 0.101885 +7.27596*10^-12 I
q = 14 --> C1/.gamma-> 0.9 = -25.9344+4.85305*10^-16 I
As we see the results are complex numbers and especially for q=14, and gamma = 0.1 the imaginary part is not negligible. So, the question is when the integrand is real, why the result of the integration is complex and has an imaginary part?
Any idea what is the problem and how to fix it?