# Different results of definite integral over complex exponential.

GROUPS:
 Andreas B. 2 Votes We are currently using Mathematica 9.0 and came across the problem, that in certain situations, Mathematica will give different results for the same definite integral. Here is a minimal working exampleIntegrate[Abs[Cos[φ]+ⅈ⁢Sin[φ]]^2,{φ,0,2⁢π}]Integrate[Abs[Exp[ⅈ φ]]^2,{φ,0,2⁢π}]The first integral gives zero, while the second one holds the correct result 2*pi. Using FullSimplify gives the correct result but is too time consuming for larger expressions.I would appreciate any help concerning this issue, as these functions are rather often used in our codes here and this really questions the reliability of Integrate and/or Abs.Thanks!
1 year ago
4 Replies
 Simon Schmidt 1 Vote Scary...  Same thing in v8. It seems to only happen when the region of integration is [0,2Pi]  or [-2Pi, 0]:Cases[ ParallelTable[  {i Pi, (i + 2) Pi, Integrate[ Abs[ Cos[x] + I Sin[x]]^2, {x, i Pi, (i + 2) Pi}]},  {i, -100, 100}], {_, _, Except[2 Pi]}](* {{-2 Pi, 0, 0}, {0, 2 Pi, 0}} *)Perhaps you can change your region of integration as a workaround.
 Simon Schmidt 1 Vote !!!DO NOT USE, MAY BREAK MANY THINGS. WAIT FOR OFFICIAL FIX!!!With that disclaimer out of the way:I got curious where this happened and Spelunked a bit.The problem arises in IntegrateImproperDumpDispatcher[f_, {x_, 0, 2 PI}]where the function is decomposed into a polynomial in Cos and Sin whose coefficients get improperly transformed for complex values. (1^2 + I^2 = 0)I decided to drop that downvalue from Dispatcher to see what happens: (* Make sure definitions are loaded *) Integrate[Abs[Cos[x] + I Sin[x]]^2, {x, 0, 2 Pi}]  dw = DownValues[IntegrateImproperDumpDispatcher]; pos = Position[dw,          HoldPattern[IntegrateImproperDumpDispatcher[f_, {x_, 0, 2 Pi}]]       ][[1, 1]]; dw = Drop[dw, {pos}]; DownValues[IntegrateImproperDumpDispatcher] = dw;Integrate[Abs[Cos[x] + I Sin[x]]^2, {x, 0, 2 Pi}](* 2 Pi :) *)To get back to normal just restart the kernel