A problem when integrate Cos[n*x]*Cos[k*x] [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












3












$begingroup$



This question already has an answer here:



  • How to force correct answers for Integrals of Cos[mx]*Cos[nx]? [duplicate]

    2 answers



When integrate the indefinite integral Cos[nx]Cos[kx] about x, where both k and n are positive integer, the result is Pi when n equals to k and 0 when n is unequal to k. However, the code



sol = Integrate[Cos[n*x]*Cos[k*x], x, -Pi, Pi, 
Assumptions -> n ∈ Integers && k ∈ Integers && n > 0 && k > 0]


gives the result (k Sin[π k + π n] - n Sin[π k + π n] +
k Sin[π k - π n] + n Sin[π k - π n])/(k^2 - n^2)
.
enter image description here



And then use the Simplify function,



Simplify[sol, Assumptions -> n ∈ Integers && k ∈ Integers && n > 0 && k > 0]


gives the result 0. Shouldn't that Integrate returns a Piecewise function like Piecewise[Pi, n == k, 0, n != k] instead?










share|improve this question











$endgroup$



marked as duplicate by Daniel Lichtblau, m_goldberg, march, Henrik Schumacher, MarcoB Jan 29 at 6:34


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















    3












    $begingroup$



    This question already has an answer here:



    • How to force correct answers for Integrals of Cos[mx]*Cos[nx]? [duplicate]

      2 answers



    When integrate the indefinite integral Cos[nx]Cos[kx] about x, where both k and n are positive integer, the result is Pi when n equals to k and 0 when n is unequal to k. However, the code



    sol = Integrate[Cos[n*x]*Cos[k*x], x, -Pi, Pi, 
    Assumptions -> n ∈ Integers && k ∈ Integers && n > 0 && k > 0]


    gives the result (k Sin[π k + π n] - n Sin[π k + π n] +
    k Sin[π k - π n] + n Sin[π k - π n])/(k^2 - n^2)
    .
    enter image description here



    And then use the Simplify function,



    Simplify[sol, Assumptions -> n ∈ Integers && k ∈ Integers && n > 0 && k > 0]


    gives the result 0. Shouldn't that Integrate returns a Piecewise function like Piecewise[Pi, n == k, 0, n != k] instead?










    share|improve this question











    $endgroup$



    marked as duplicate by Daniel Lichtblau, m_goldberg, march, Henrik Schumacher, MarcoB Jan 29 at 6:34


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




















      3












      3








      3


      1



      $begingroup$



      This question already has an answer here:



      • How to force correct answers for Integrals of Cos[mx]*Cos[nx]? [duplicate]

        2 answers



      When integrate the indefinite integral Cos[nx]Cos[kx] about x, where both k and n are positive integer, the result is Pi when n equals to k and 0 when n is unequal to k. However, the code



      sol = Integrate[Cos[n*x]*Cos[k*x], x, -Pi, Pi, 
      Assumptions -> n ∈ Integers && k ∈ Integers && n > 0 && k > 0]


      gives the result (k Sin[π k + π n] - n Sin[π k + π n] +
      k Sin[π k - π n] + n Sin[π k - π n])/(k^2 - n^2)
      .
      enter image description here



      And then use the Simplify function,



      Simplify[sol, Assumptions -> n ∈ Integers && k ∈ Integers && n > 0 && k > 0]


      gives the result 0. Shouldn't that Integrate returns a Piecewise function like Piecewise[Pi, n == k, 0, n != k] instead?










      share|improve this question











      $endgroup$





      This question already has an answer here:



      • How to force correct answers for Integrals of Cos[mx]*Cos[nx]? [duplicate]

        2 answers



      When integrate the indefinite integral Cos[nx]Cos[kx] about x, where both k and n are positive integer, the result is Pi when n equals to k and 0 when n is unequal to k. However, the code



      sol = Integrate[Cos[n*x]*Cos[k*x], x, -Pi, Pi, 
      Assumptions -> n ∈ Integers && k ∈ Integers && n > 0 && k > 0]


      gives the result (k Sin[π k + π n] - n Sin[π k + π n] +
      k Sin[π k - π n] + n Sin[π k - π n])/(k^2 - n^2)
      .
      enter image description here



      And then use the Simplify function,



      Simplify[sol, Assumptions -> n ∈ Integers && k ∈ Integers && n > 0 && k > 0]


      gives the result 0. Shouldn't that Integrate returns a Piecewise function like Piecewise[Pi, n == k, 0, n != k] instead?





      This question already has an answer here:



      • How to force correct answers for Integrals of Cos[mx]*Cos[nx]? [duplicate]

        2 answers







      calculus-and-analysis






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 24 at 3:42









      Mr.Wizard

      231k294761046




      231k294761046










      asked Jan 24 at 2:05









      shelure21shelure21

      184




      184




      marked as duplicate by Daniel Lichtblau, m_goldberg, march, Henrik Schumacher, MarcoB Jan 29 at 6:34


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by Daniel Lichtblau, m_goldberg, march, Henrik Schumacher, MarcoB Jan 29 at 6:34


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















          1 Answer
          1






          active

          oldest

          votes


















          5












          $begingroup$

          This is well know issue. One way to handle it is



          Simplify[ sol, 
          Assumptions -> Element[n, Integers] && Element[k, Integers] && n > 0 && k > 0 && k != n]

          (* 0 *)


          And



          Simplify[ Limit[sol, k -> n], 
          Assumptions -> Element[n, Integers] && Element[k, Integers] && n > 0 && k > 0 && k == n ]

          (* Pi *)


          See



          should-integrate-detect-orthogonality-of-functions-in-the-integrand



          And



          What assumptions to use to check for orthogonality



          And



          should-integrate-have-given-zero-for-this-integral



          And



          proper-way-to-simplify-integral-result-in-mathematica-given-integer-constraints



          And



          usage-of-assuming-for-integration






          share|improve this answer









          $endgroup$












          • $begingroup$
            You can shorten the Limit to Limit[sol, k -> n, Assumptions -> Element[n, Integers]]
            $endgroup$
            – Bob Hanlon
            Jan 24 at 5:41










          • $begingroup$
            @BobHanlon thanks. I am sure you are right. I was only copying what the OP had in there. But good point.
            $endgroup$
            – Nasser
            Jan 24 at 5:56

















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          5












          $begingroup$

          This is well know issue. One way to handle it is



          Simplify[ sol, 
          Assumptions -> Element[n, Integers] && Element[k, Integers] && n > 0 && k > 0 && k != n]

          (* 0 *)


          And



          Simplify[ Limit[sol, k -> n], 
          Assumptions -> Element[n, Integers] && Element[k, Integers] && n > 0 && k > 0 && k == n ]

          (* Pi *)


          See



          should-integrate-detect-orthogonality-of-functions-in-the-integrand



          And



          What assumptions to use to check for orthogonality



          And



          should-integrate-have-given-zero-for-this-integral



          And



          proper-way-to-simplify-integral-result-in-mathematica-given-integer-constraints



          And



          usage-of-assuming-for-integration






          share|improve this answer









          $endgroup$












          • $begingroup$
            You can shorten the Limit to Limit[sol, k -> n, Assumptions -> Element[n, Integers]]
            $endgroup$
            – Bob Hanlon
            Jan 24 at 5:41










          • $begingroup$
            @BobHanlon thanks. I am sure you are right. I was only copying what the OP had in there. But good point.
            $endgroup$
            – Nasser
            Jan 24 at 5:56















          5












          $begingroup$

          This is well know issue. One way to handle it is



          Simplify[ sol, 
          Assumptions -> Element[n, Integers] && Element[k, Integers] && n > 0 && k > 0 && k != n]

          (* 0 *)


          And



          Simplify[ Limit[sol, k -> n], 
          Assumptions -> Element[n, Integers] && Element[k, Integers] && n > 0 && k > 0 && k == n ]

          (* Pi *)


          See



          should-integrate-detect-orthogonality-of-functions-in-the-integrand



          And



          What assumptions to use to check for orthogonality



          And



          should-integrate-have-given-zero-for-this-integral



          And



          proper-way-to-simplify-integral-result-in-mathematica-given-integer-constraints



          And



          usage-of-assuming-for-integration






          share|improve this answer









          $endgroup$












          • $begingroup$
            You can shorten the Limit to Limit[sol, k -> n, Assumptions -> Element[n, Integers]]
            $endgroup$
            – Bob Hanlon
            Jan 24 at 5:41










          • $begingroup$
            @BobHanlon thanks. I am sure you are right. I was only copying what the OP had in there. But good point.
            $endgroup$
            – Nasser
            Jan 24 at 5:56













          5












          5








          5





          $begingroup$

          This is well know issue. One way to handle it is



          Simplify[ sol, 
          Assumptions -> Element[n, Integers] && Element[k, Integers] && n > 0 && k > 0 && k != n]

          (* 0 *)


          And



          Simplify[ Limit[sol, k -> n], 
          Assumptions -> Element[n, Integers] && Element[k, Integers] && n > 0 && k > 0 && k == n ]

          (* Pi *)


          See



          should-integrate-detect-orthogonality-of-functions-in-the-integrand



          And



          What assumptions to use to check for orthogonality



          And



          should-integrate-have-given-zero-for-this-integral



          And



          proper-way-to-simplify-integral-result-in-mathematica-given-integer-constraints



          And



          usage-of-assuming-for-integration






          share|improve this answer









          $endgroup$



          This is well know issue. One way to handle it is



          Simplify[ sol, 
          Assumptions -> Element[n, Integers] && Element[k, Integers] && n > 0 && k > 0 && k != n]

          (* 0 *)


          And



          Simplify[ Limit[sol, k -> n], 
          Assumptions -> Element[n, Integers] && Element[k, Integers] && n > 0 && k > 0 && k == n ]

          (* Pi *)


          See



          should-integrate-detect-orthogonality-of-functions-in-the-integrand



          And



          What assumptions to use to check for orthogonality



          And



          should-integrate-have-given-zero-for-this-integral



          And



          proper-way-to-simplify-integral-result-in-mathematica-given-integer-constraints



          And



          usage-of-assuming-for-integration







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 24 at 2:25









          NasserNasser

          57.8k488205




          57.8k488205











          • $begingroup$
            You can shorten the Limit to Limit[sol, k -> n, Assumptions -> Element[n, Integers]]
            $endgroup$
            – Bob Hanlon
            Jan 24 at 5:41










          • $begingroup$
            @BobHanlon thanks. I am sure you are right. I was only copying what the OP had in there. But good point.
            $endgroup$
            – Nasser
            Jan 24 at 5:56
















          • $begingroup$
            You can shorten the Limit to Limit[sol, k -> n, Assumptions -> Element[n, Integers]]
            $endgroup$
            – Bob Hanlon
            Jan 24 at 5:41










          • $begingroup$
            @BobHanlon thanks. I am sure you are right. I was only copying what the OP had in there. But good point.
            $endgroup$
            – Nasser
            Jan 24 at 5:56















          $begingroup$
          You can shorten the Limit to Limit[sol, k -> n, Assumptions -> Element[n, Integers]]
          $endgroup$
          – Bob Hanlon
          Jan 24 at 5:41




          $begingroup$
          You can shorten the Limit to Limit[sol, k -> n, Assumptions -> Element[n, Integers]]
          $endgroup$
          – Bob Hanlon
          Jan 24 at 5:41












          $begingroup$
          @BobHanlon thanks. I am sure you are right. I was only copying what the OP had in there. But good point.
          $endgroup$
          – Nasser
          Jan 24 at 5:56




          $begingroup$
          @BobHanlon thanks. I am sure you are right. I was only copying what the OP had in there. But good point.
          $endgroup$
          – Nasser
          Jan 24 at 5:56


          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?