Re: A question about $Assumptions

*To*: mathgroup at smc.vnet.net*Subject*: [mg68965] Re: A question about $Assumptions*From*: Roland Franzius <roland.franzius at uos.de>*Date*: Fri, 25 Aug 2006 05:35:29 -0400 (EDT)*Organization*: Universitaet Hannover*References*: <echdmb$oji$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Led schrieb: > Mathematica 5.2 (Windows) gives: > > In[1]:= > Integrate[ Cos[m*x] * Cos[n*x] ,{x,0,Pi}] > > Out[1]= > \!\(\(m\ Cos[n\ Ï?]\ Sin[m\ Ï?] - n\ Cos[m\ Ï?]\ Sin[n\ Ï?]\)\/\(m\^2 - > n\^2\)\) > > which is the expected result. But if instead one writes > > In[1]:= > $Assumptions={{m,n}â??Integers}; > Integrate[ Cos[m*x] * Cos[n*x] ,{x,0,Pi}] > > Out[1]= > 0 > > the result is correct only if m~=n. > > What's the problem with $Assumptions? > Shouldn't it be used that way? > The problem is evaluation order. In the general formula setting n Integer generates zero before a check on m is performed. Calculate the diagonal and zero cases separately Integrate[ Cos[n*x] * Cos[n*x] ,{x,0,Pi}] pi/2 Integrate[ Cos[0*x] * Cos[0*x] ,{x,0,Pi}] pi -- Roland Franzius