# Mathematica integration error

Integrate[Integrate[Abs[Exp[2*Pi*I*x] + Exp[2*Pi*I*y]], {x, 0, 1}], {y, 0, 1}] yields 0 as result.

This cannot be correct, because the integrand is positive and nonzero in the indicated region.

Wolfram Alpha sais: Standard computation time exceeded, so I do not know if there the same comes out.

Any idea what is going on?

You can express the integrand in a different way :

FullSimplify[ComplexExpand[Abs[Exp[2*Pi*I*x] + Exp[2*Pi*I*y]], TargetFunctions -> {Re, Im}]]
(* 2 Sqrt[Cos[\[Pi] (x - y)]^2] *)


Now

Integrate[2 Sqrt[Cos[\[Pi] (x - y)]^2], {x, 0, 1}]
(* 0 *)


but

Integrate[2 Abs[Cos[\[Pi] (x - y)]], {x, 0, 1}, {y, 0, 1}]
(* 4/\[Pi] *)

NIntegrate[Abs[Exp[2*Pi*I*x] + Exp[2*Pi*I*y]], {x, 0, 1}, {y, 0, 1}]
(* 1.27324 *)


So the square root seems to be the root of the problem.

• Since the integral is on the unit square, just include the assumptions {0<=x<=1, 0<=y<=1} in Simplify. expr = Abs[Exp[2*Pi*I*x] + Exp[2*Pi*I*y]] // ComplexExpand // Simplify[#, {0 <= x <= 1, 0 <= y <= 1}] & gives 2*Abs[Cos[Pi*(x - y)]] and, as you showed, Integrate[expr, {x, 0, 1}, {y, 0, 1}] gives 4/Pi. Oct 31, 2014 at 14:23
• @BobHanlon Thanks. Oct 31, 2014 at 14:34
• you need only the assumption Element[{x, y}, Reals] ( adding that assumption to Integrate does not fix the original anomaly though ) Oct 31, 2014 at 16:08
• Integrate[ Simplify[ComplexExpand[ Abs[Exp[2*PiIx] + Exp[2*PiIy]]], {x, y} [Element] Reals], {x, 0, 1}, {y, 0, 1}] -> 4/pi Oct 31, 2014 at 21:14