# When and why are Assuming and Assumptions not equivalent? [duplicate]

In this question there's an example of an integral where using Assuming and Assumptions give different results:

In[1]:= Integrate[Cos[n x], {x, 0, Pi}, Assumptions -> Element[n, Integers]]
Out[1]= Sin[n π]/n

In[2]:= Assuming[Element[n, Integers], Integrate[Cos[n x], {x, 0, Pi}]]
Out[2]= 0

In[3]:= Integrate[Cos[n x], {x, 0, Pi}, Assumptions -> Element[n, Integers]]
Out[3]= Sin[n π]/n


Now let's clear the system cache (or restart the kernel if you like) and try again, but now in a different order:

In[4]:= ClearSystemCache[] (* fresh start! *)

In[5]:= Assuming[Element[n, Integers], Integrate[Cos[n x], {x, 0, Pi}]]
Out[5]= 0

In[6]:= Integrate[Cos[n x], {x, 0, Pi}, Assumptions -> Element[n, Integers]]
Out[6]= 0


To make things even more weird, the results are affected by the order these two versions are evaluated (clearly due to caching). In[6] and In[3] are the same but they return different results.

I always assumed that using Assuming or Assumptions with built-in functions should be equivalent. It seems this is not true. I can imagine that Integrate uses something internally (e.g. Refine) that is affected by the global Assuming, but not by Assumptions.

Generally, when are Assuming and Assumptions not equivalent?

Is the result I quoted above a bug?

EDIT: As Artes and Michael noted in the comments, this is explained by Daniel Lichtblau here. My only remaining worry is that the results are cached and effectively depend on the order of evaluation.

• I remember Daniel Lichtblau answered such a question (or closely related) more or less one year ago. Feb 11, 2014 at 14:00
• @Artes This one? mathematica.stackexchange.com/a/19894 Feb 11, 2014 at 14:02
• @MichaelE2 Perheps I remembered this one but not quite sure at the moment. Feb 11, 2014 at 14:04
• @Artes So then both this one and the other one are practically duplicates of that question. Do you agree? Feb 11, 2014 at 14:12
• @Szabolcs I marked the other question as a duplicate, but I think the problem you pointed out here (dependence on the order of evaluation) is worth of explanation. Feb 11, 2014 at 15:07