4
$\begingroup$

Can somebody help me understand why Mathematica returns the following?

In[1]= f=Cos[j x]Cos[(n-2b-k)x]Cos[2(b-ell)x];
In[2]= Simplify[Integrate[f,{x,0,\[Pi]}],
         Assumptions->b\[Element]Integers
         &&ell\[Element]Integers
         &&n\[Element]Integers
         &&k\[Element]Integers
         &&j\[Element]Integers]
Out[2]= 0
In[3]= g = f /. {j -> 2, b -> 3, n -> 11, ell -> 0, k -> 1};
In[4]= Integrate[g, {x, 0, \[Pi]}];
Out[4]= \[Pi]/4;

Thanks.

$\endgroup$
1
$\begingroup$

This example shows the need to be carefull when integrating trig-functions with integer parameters.

One way out is to use "GenerateConditions->True", like @Shinrei proposed.

If there is an error message with your special parameter values, add a small epsilon to each and build the Limit epsilon->0 and you get the right result.

 int = Integrate[f, {x, 0, Pi}, GenerateConditions -> True]

 int /. {j -> 2, b -> 3, n -> 11, ell -> 0, k -> 1}

 (*   During evaluation of In[4]:= Power::infy: Infinite expression 1/0 encountered. >>

      During evaluation of In[4]:= Infinity::indet: Indeterminate expression 0 ComplexInfinity encountered. >>

 Out[4]=  Indeterminate    *)

 Limit[int /. ({j -> 2, b -> 3, n -> 11, ell -> 0, 
    k -> 1} /. (u_ -> v_) -> (u -> v + Epsilon)), Epsilon -> 0]

 (*   \[Pi]/4    *)
$\endgroup$
0
$\begingroup$
Integrate[f, x]/. {j -> 2, b -> 3, n -> 11, ell -> 0, k -> 1}

Returns:

Power::infy: Infinite expression 1/0 encountered. Infinity::indet: Indeterminate expression 0 ComplexInfinity encountered.

so this values for j,b,n,ell,k should be treated as a separate case

$\endgroup$
  • 1
    $\begingroup$ I'm struggling to see what the point of assuming something is an integer is then. $\endgroup$ – jth Apr 29 '17 at 7:17
  • $\begingroup$ But expression like $Assumptions = b \[Element] Integers && ell \[Element] Integers && n \[Element] Integers && k \[Element] Integers && j \[Element] Integers; f = Cos[j x] Cos[(n - 2 b - k) x] Cos[2 (b - ell) x]; Integrate[f, {x, 0, \[Pi]}, GenerateConditions -> True] will not give a user the chance to know that something is wrong. A user might be interested in usage of Integer assumptions in notebook for other purposes. And it looks like user have to cancel such assumptions each time when Integrate is supposed to be called. $\endgroup$ – Shinrei Apr 29 '17 at 7:24
  • $\begingroup$ to @jth I think that the goal is to simplify expressions like Sin[n Pi] $\endgroup$ – Ryhor Apr 29 '17 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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