Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
    
which version of Mathematica are you using? –  chuy Feb 19 '13 at 15:08
    
7.0.1.0 for MacOSx 32bit –  Christian Feb 19 '13 at 15:09
    
Maybe related to this ? –  b.gatessucks Feb 19 '13 at 15:22

2 Answers 2

up vote 14 down vote accepted

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.

share|improve this answer
2  
Thanks for explaining how the assumptions are working! I have one more question though. 0 is clearly an integer and Sin[k*Pi]/k for k=0 gives "Indeterminate". How can Mathematica then Simplify Sin[k*Pi]/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. –  Christian 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. –  Christian 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 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 π *)
share|improve this answer
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. –  Christian 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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.