Artes gives a good overview of the problems inherent in symbolic integration. Changing the form of the integral can yield different results, but then the problem is determining the correct one.
Using ExpToTrig
on the integrand yields a different result:
ans1 = Integrate[Exp[-I θ]/(1 + b Cos[θ]),
{θ, 0, 2 π}, Assumptions -> b < 1 && b > -1]
ans2 = Integrate[Exp[-I θ]/(1 + b Cos[θ]) // ExpToTrig,
{θ, 0, 2 π}, Assumptions -> b < 1 && b > -1]
(*
(2 π)/b
ConditionalExpression[(2 (1 - 1/Sqrt[1 - b^2]) π)/b, b != 0]
*)
We can compare the two answers. Turning off symbolic preprocessing ensures that the NIntegrate will use the formula just as we pass it. (One can achieve a similar effect by defining f[θ_?NumericQ] := Exp[-I θ]/(1 + b Cos[θ])
and using f[θ]
for the integrand.
Block[{b = 0.5},
{NIntegrate[Exp[-I θ]/(1 + b Cos[θ]),
{θ, 0, 2 π}, Method -> {Automatic, "SymbolicProcessing" -> 0}],
ans1, ans2}
]
(*
{-1.94402 + 3.65803*10^-16 I, 12.5664, -1.94402}
*)
So the second method seems to give a correct result. More values of b
could be checked for further verification.
Another way to modify the form of the integral is to change the interval:
Integrate[Exp[-I θ]/(1 + b Cos[θ]),
{θ, -π, π}, Assumptions -> b < 1 && b > -1]
(*
ConditionalExpression[(
2 (1 - 1/Sqrt[1 - b^2]) π)/b, (b != 0 && Re[1/Sqrt[b]] != 0) || b < 0]
*)
Or one can break down the real and imaginary parts (the third one, with the parts combine is basically what ExpToTrig
does):
Integrate[Cos[θ]/(1 + b Cos[θ]),
{θ, 0, 2 π}, Assumptions -> b < 1 && b > -1]
Integrate[Sin[θ]/(1 + b Cos[θ]),
{θ, 0, 2 π}, Assumptions -> b < 1 && b > -1]
Integrate[(Cos[θ] - I Sin[θ])/(1 + b Cos[θ]),
{θ, 0, 2 π}, Assumptions -> b < 1 && b > -1]
(*
ConditionalExpression[(2 (1 - 1/Sqrt[1 - b^2]) π)/b, b != 0]
ConditionalExpression[0, b != 0]
ConditionalExpression[(2 (1 - 1/Sqrt[1 - b^2]) π)/b, b != 0]
*)
One thing worth noting is that in this form, the integrands are real-valued functions (ignoring the complex coefficient in the third form) of real variables. In fact, they are rational functions of sine and cosine, which can be converted to rational function via substitution, although I do not know how Mathematica handles them. The Exp[I θ]
probably causes Mathematica to invoke a different algorithm to deal with functions of a complex variable.
If one wants, may do the substitution θ -> 2 ArcTan[t]
, although this will be equivalent to the integral from -π
to π
:
Integrate[TrigExpand@FullSimplify[
Exp[-I θ]/(1 + b Cos[θ]) Dt[θ] /.
θ -> 2 ArcTan[t], t ∈ Reals] /. Dt[t] -> 1,
{t, -Infinity, Infinity}, Assumptions -> -1 < b < 1]
(*
(2 (π - π/Sqrt[1 - b^2]))/b
*)
2*%pi/b * (2*sqrt(1-b^2)+b^2-2)/(sqrt(1-b^2)+b^2-1)
. When computing with +i instead of -i in the exponential, it gives instead2*%pi/b * (sqrt(1-b^2)-1)/sqrt(1-b^2)
, but it's actually the same. $\endgroup$Manipulate
to see the dependence onb
of the singularities of the integrand in the complexTheta
plane:Manipulate[ContourPlot[Abs[Exp[-I Theta]/(1 + b Cos[Theta]) /. {Theta -> ThetaR + I ThetaI}], {ThetaR, -1, 2 Pi + 1}, {ThetaI, -Pi - 1, Pi + 1}, PlotRange -> {Automatic, 30}, Contours -> 50, Epilog -> {Red, Thick, Line[{{0, 0}, {2 Pi, 0}}]}], {{b, 0.5}, -1, 1}]
. You need to ensure that the path of integration goes appropriately around the singularities in order to get the intended result. $\endgroup$Series
approach is offered only as a way of helping Mathematica to compute the answer that you seek. As for the complex roots problem, I don't have any inside knowledge about how Mathematica does its integrations or how it handles singularities that may (or may not) be important. See the answer from @artes below for more details on this, where I agree with the statement that this is all due to "imperfectness of symbolic integration". When there are singularities lurking around, you have to appeal to the underlying physics (or whatever) of the problem to decide how to handle them. $\endgroup$Limit
. Will try to sort it out (usual caveat: roughly even odds it sorts me out instead). $\endgroup$