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. – May 19 '14 at 10:36Manipulateto see the dependence onbof the singularities of the integrand in the complexThetaplane: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. – Stephen Luttrell May 19 '14 at 11:07Assumption->Element[x,Reals]– May 19 '14 at 11:44Manipulatein my previous comment shows that the position of the singularities of the integrand depends strongly on the value ofb, so I can't see how any automatic integration scheme - e.g. integration along realTheta- will necessarily give you the "right" answer. In general, the answer depends on how the integration path winds around the singularities. However, I concede that in this particular case I haven't looked closely at exactly what is going on, other than to observe the "wandering singularities", which alerts me to the need to take care. – Stephen Luttrell May 19 '14 at 11:59bapproach that works. Compute the coefficient ofb^nusingcoeff[n_] = Integrate[Exp[-I Theta]/(1 + b Cos[Theta]) // SeriesCoefficient[#, {b, 0, n}] & // Evaluate, {Theta, 0, 2 Pi}, Assumptions -> (n >= 0 && n \[Element] Integers)] // FullSimplify- this takes a while to compute. Sum the series usingintegral[b_] = (Sum[b^n coeff[n], {n, 0, Infinity}]) // FullSimplify, which gives((-2 + 2 b^4 + (-1 + b^2) Sqrt[1 + b^2] + Sqrt[1 + b^2] Sqrt[1 - b^4] + Sqrt[2 - 2 b^4] Sqrt[1 + Sqrt[1 - b^4]]) \[Pi])/(b(-1 + b^4)). – Stephen Luttrell May 19 '14 at 12:28changevarfollowed bytrigexpandandratsimp). This is an easy integral, even without series (of course, one has still to be careful with integration bounds). – May 19 '14 at 12:46Seriesapproach 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. – Stephen Luttrell May 19 '14 at 13:40Limit. Will try to sort it out (usual caveat: roughly even odds it sorts me out instead). – Daniel Lichtblau May 22 '14 at 15:52