Great Answers to
Questions About Everything


For some reason, when I enter the following integration in Mathematica

Assuming[{k ∈ Integers}, Integrate[ Exp[ I k t], {t, -π, π}]]

the result turns out to be 0. However, clearly, if $k = 0$, the integral should evaluate to $2\pi$ instead. Can someone explain this behavior?

{ asked by Christian }


I can explain this.

The definite flavor of Integrate works with assumptions in a few ways. One is to use them in Simplify, Refine, and a few other places that accept Assumptions, to do what they will in the hope of attaining a better result (it also uses them to determine convergence and presence or absence of path singularities). Those places also get the $Assumptions default when there are no explicit Assumptions option settings in Integrate, hence one can do Assuming[...,Integrate[...]] with similar effect. But there is a difference.

Simplify et al return "generic results", so e.g. Sin[ k π]/k will simplify to 0 if told that k is an integer.

Simplify[ Sin[ k π]/k, Assumptions-> k ∈ Integers]                 

(* Out[4]= 0 *)

Integrate knows Simplify will do this, and wishes it would not (always) be so aggressive. So it takes its Assumptions option and recasts things regarded as Integers into Reals. That's why the related example

Integrate[ Exp[ I k t], {t, -π, π}, Assumptions -> {k ∈ Integers}]

manages to provide a correct result. But Integrate does not attempt to mess with $Assumptions that may have been set outside its scope. This is what happens when one instead uses the Assuming[...,Integrate[...]] construction. In that case a trig result like the one I showed will be (over?-)simplified to zero.

Upshot: Integrate subverts the explicit Integrate assumptions of the user in order to avoid this generic simplification pitfall. It's not clear to me at this point which is the bug and which is the feature. Since there are valid arguments for either, and since I think tangling with global $Assumptions inside Integrate is a risky endeavor, I regard this as best left alone.

{ answered by Daniel Lichtblau }