Proper way to simplify integral result in Mathematica given integer constraints

后端 未结 4 1729
余生分开走
余生分开走 2021-02-19 14:59

Evaluating the following integral should be non-zero, and mathematica correctly gives a non-zero result

Integrate[ Cos[ (Pi * x)/2 ]^2 * Cos[ (3*Pi*x)/2 ]^2, {x,         


        
4条回答
  •  情歌与酒
    2021-02-19 15:38

    Lets use some conclusive conditions about the two integers m=n||m!=n.

    Assuming[{(n \[Element] Integers && m \[Element] Integers && m == n)},
    Integrate[Cos[(Pi x)/2]^2 Cos[((2 n + 1) Pi x)/2] Cos[((2 m + 1) Pi x)/2],
    {x, -1, 1}]]
    

    The answer for this case is 1/2. For the other case it is

    Assuming[{(n \[Element] Integers && m \[Element] Integers && m != n)},
    Integrate[
    Cos[(Pi x)/2]^2 Cos[((2 n + 1) Pi x)/2] Cos[((2 m + 1) Pi x)/
     2], {x, -1, 1}]]
    

    and the answer is 0.

    However I am amazed to see that if we add this two conditions as an "either or stuff", Mathematica returns one zero after integration. I mean in case of the following I am getting only zero but not ``1/2||0`.

    Assuming[{(n \[Element] Integers && m \[Element] Integers && 
     m == n) || (n \[Element] Integers && m \[Element] Integers && 
     m != n)}, 
    Integrate[
    Cos[(Pi x)/2]^2 Cos[((2 n + 1) Pi x)/2] Cos[((2 m + 1) Pi x)/
     2], {x, -1, 1}]]
    

    By the way we can see the conditions exclusively where this integral becomes Indeterminate.

    res = Integrate[
    Cos[(Pi x)/2]^2 Cos[((2 n + 1) Pi x)/2] Cos[((2 m + 1) Pi x)/
      2], {x, -1, 1}] // Simplify
    

    The output is here.

    enter image description here

    Now lets see all the relations m and n can have to make the Integral bad!

    BadPart = (res*4 Pi);
    Flatten@(Solve[(Denominator[#] == 0), m] & /@ 
     Table[BadPart[[i]], {i, 1, Length@BadPart}] /. 
    Rule -> Equal) // TableForm
    

    enter image description here

    So these are the special cases which as Sjoerd mentioned are having infinite instances.

    BR

提交回复
热议问题