3
$\begingroup$

Consider the following function:

f = (E^(2 I c \[Phi]) - (E^(2 I \[Phi]))^c) (E^(2 I \[Phi]))^n

Integrating this function with respect to \[Phi] from -\[Pi] to \[Pi] apparently gives:

int1 = Integrate[ f , {\[Phi], -\[Pi], \[Pi]}]

enter image description here

Suppose we would like n to be an integer, so we fully simplify as follows:

Assuming[Element[n, Integers], int1 // FullSimplify]

enter image description here

which, in general, is a non-zero quantity. However, for integer n we should be able to do the integral directly with this assumption in place. This suggests:

int2 = Assuming[Element[n, Integers], Integrate[ f , {\[Phi], -\[Pi], \[Pi]}] ]

0

Now it seems that the integral is actually zero for general integer n! Surely, only one of the two results can be true. Which one is it? And why is Mathematica producing these discrepancies? Is this a bug in Mathematica?

$\endgroup$
2
  • 2
    $\begingroup$ possible duplicate: Usage of Assuming for Integration and links therein. $\endgroup$ Oct 9, 2018 at 3:17
  • $\begingroup$ $$int2 = Assuming[Element[n, Integers], Integrate[ f , {\[Phi], -\[Pi], \[Pi]}] ]$$ Mathematica gives a nonzero answer for nonIntegral value of $c$ (Works fine ) otherwise it gives $0$ (a wrong answer). $\endgroup$ Oct 9, 2018 at 6:17

1 Answer 1

2
$\begingroup$

For a proper usage of "Assumptions" for integration, Please go through the post:
Proper usage of Assumptions

Following works fine for your case.

  Block[{$Assumptions = n \[Element] Integers}, Integrate[f, {\[Phi], -\[Pi], \[Pi]}, Assumptions -> True]]

This gives: $\frac{\sin (2 \pi (c+n))-2 \sin (\pi (c+n))}{c+n}$; which can be simplified to your first answer.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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