Forums before death by AOL, social media and spammers... "We can't have nice things"
|    sci.math.symbolic    |    Symbolic algebra discussion    |    10,432 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 9,839 of 10,432    |
|    Nasser M. Abbasi to Tom D    |
|    Re: how does your CAS handle this integr    |
|    04 Mar 18 19:11:42    |
   
   From: nma@12000.org   
      
   On 3/4/2018 1:59 PM, Tom D wrote:   
   > This is what I get in Mathematica 11.2 on Windows:   
   >   
   > In[37]:= $Version   
   > Out[37]= 11.2.0 for Microsoft Windows (64-bit) (September 11, 2017)   
   >   
   > In[39]:= Integrate[ Cos[n x] Sin[x]^2 Cos[x], {x,0,2\[Pi]}]   
   > Out[39]= -((2 n Sin[2 n \[Pi]])/(9-10 n^2+n^4))   
   >   
   > (* See here why we get non-zero result at n=1,3 - roots of the denominator *)   
   >   
   > In[40]:= Factor[%]   
   > Out[40]= -((2 n Sin[2 n \[Pi]])/((-3+n) (-1+n) (1+n) (3+n)))   
   >   
   > In[41]:= f[n_]:=Integrate[ Cos[n x] Sin[x]^2 Cos[x], {x,0,2\[Pi]}]   
   >   
   > In[43]:= Table[{n,f[n]},{n,0,8}]//TableForm   
   >   
   > Out[43]//TableForm=   
   > 0 0   
   > 1 \[Pi]/4   
   > 2 0   
   > 3 -(\[Pi]/4)   
   > 4 0   
   > 5 0   
   > 6 0   
   > 7 0   
   > 8 0   
   >   
   > I don't know why it is working for me ...   
   >   
   > Regards,   
   > Tom   
      
   Sorry, but I do not understand what you mean when you say   
   "I don't know why it is working for me ..."   
      
   The problem is when using assumptions, which you did not do.   
      
   These type of problems are very common. I've collected   
   few examples here, some I found, and some from others:   
      
   ========== bug one ===============================   
   (* by Peeter Joot*)   
   FullSimplify[Integrate[Cos[(Pi x)/2]^2 Cos[((2 n+1) Pi x)/2]   
    Cos[((2 m+1) Pi x)/2],{x,-1,1}],Element[{m,n},Integers]]   
   (*0*)   
      
   But   
      
   m=1;n=1;   
   FullSimplify[Integrate[Cos[(Pi x)/2]^2 Cos[((2 n+1) Pi x)/2]   
    Cos[((2 m+1) Pi x)/2],{x,-1,1}]]   
      
   (*1/2*)   
      
   ============ bug 2 ==============================   
   Simplify[Integrate[Sin[3 x] Sin[n x], {x, 0, Pi},   
    Assumptions -> Element[n, Integers] && n > 0]]   
   (* 0 *)   
      
   but   
      
   n=3;   
   Simplify[Integrate[Sin[3 x] Sin[n x],{x,0,Pi}]]   
    (* Pi/2 *)   
      
   =========== bug 3 ===========================   
   (* by JM *)   
   FourierCosCoefficient[Cos[x] Sin[x]^2, x, n]   
   Out[2]= 0   
      
   n = 1;   
   FourierCosCoefficient[Cos[x] Sin[x]^2, x, n]   
   Out[6]= 1/4   
      
   n = 3;   
   FourierCosCoefficient[Cos[x] Sin[x]^2, x, n]   
   Out[8]= -(1/4)   
      
   ============= bug 4 =====================   
      
   Clear[n]   
   integrand = Cos[x]*Sin[x]^2*Cos[n*x];   
   Assuming[Element[n, Integers] && n > 0,Integrate[integrand, {x, 0, 2*Pi}]]   
   Out[10]= 0   
      
   n = 1;   
   Assuming[Element[n, Integers] && n > 0,Integrate[integrand, {x, 0, 2*Pi}]]   
   Out[12]= -(Pi/4)   
      
   In[13]:= n = 3;   
   Assuming[Element[n, Integers] && n > 0,Integrate[integrand, {x, 0, 2*Pi}]]   
   Out[14]= -(Pi/4)   
      
   And so one. One can sit down and come with infinite number of   
   such problems.   
      
   The issue is not with Integrate per say. It is that CAS do not   
   process assumptions correctly. It gives a generic result, which   
   can be not valid for some specific values.   
      
   I find this worst than not giving any result. I think this is what   
   they call false negative? or something like this.   
      
   Lesson of the day: Do not trust CAS result. Always double check.   
      
   --Nasser   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca