# Usage of Assuming for Integration

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?

-
which version of Mathematica are you using? – chuy Feb 19 '13 at 15:08
7.0.1.0 for MacOSx 32bit – TriSSSe Feb 19 '13 at 15:09
Maybe related to this ? – b.gatessucks Feb 19 '13 at 15:22
Another recent example here mathematica.stackexchange.com/questions/97154/… – dimitris Oct 16 '15 at 12:12

## 2 Answers

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. - Thanks for explaining how the assumptions are working! I have one more question though. 0 is clearly an integer and Sin[kPi]/k for k=0 gives "Indeterminate". How can Mathematica then Simplify Sin[kPi]/k for k being integer to 0? I would expect a conditional expression (Indeterminate for k=0, and 0 else), or at least some kind of warning. – TriSSSe Feb 21 '13 at 9:47 That's what I meant by giving a "generic" result. It holds for all but finitely many cases. – Daniel Lichtblau Feb 21 '13 at 14:29 Ok after googling "mathematica generic results", it now makes sense. As a beginner, I was not aware of this behavior. Thanks again. – TriSSSe Feb 22 '13 at 8:38 There's one problem with this difference between Assuming and Assumptions: the result gets cached if Assuming is used first, and the Assumptions version will return the cached result later. – Szabolcs Feb 11 '14 at 14:15 Try :  Integrate[ Exp[ I k t], {t, -π, π}, Assumptions -> {k ∈ Integers}] (* (2 Sin[k π])/k *) Limit[ Integrate[ Exp[ I k t], {t, -π, π}, Assumptions -> {k ∈ Integers}] , k -> 0] (* 2 π *)  - I thought Assuming[...,Integrate[...]] was equivalent to Integrate[..., Assumptions->...] What's the difference? – ssch Feb 19 '13 at 14:39 @ssch I don't know, but I've noticed the difference several times. It has appeared on the site before I think. – b.gatessucks Feb 19 '13 at 14:48 Now I am even more confused. So apparently it makes a difference how one specifies assumptions, which should not happen? But then again, I am still convinced that the output to my original line of code is just plain wrong. That is what I cannot get into my head. – TriSSSe Feb 19 '13 at 14:54 @Christian Agreed, this is just unexpected and confusing Assuming[k \[Element] Integers, {$Assumptions,Integrate[Exp[I*k*t], {t, -Pi, Pi}, Assumptions->\$Assumptions]}] gives {k \[Element] Integers, 0} – ssch Feb 19 '13 at 15:01