Re: Mistake in applying a rule

*To*: mathgroup at smc.vnet.net*Subject*: [mg80677] Re: Mistake in applying a rule*From*: Szabolcs <szhorvat at gmail.com>*Date*: Tue, 28 Aug 2007 06:41:33 -0400 (EDT)*Organization*: University of Bergen*References*: <fb0f17$f05$1@smc.vnet.net>

Steven Siew wrote: > Hi, > > I'm trying to show that Integrate[Cos[x-a]] is Sin[x-a] + C > > I manage to get Simplify @ Integrate[Cos[x-a]] to give -Sin[a-x] > > This is fine because Sin[-x] is equal to -Sin[x] > > But when I apply the rule Times[-1,Sin[Plus[g_,Times[-1,h_]]]] -> > Sin[h-g] it fails. Hi, Your replacement rule is working correctly, however, for some reason Mathematica likes to sort the variables inside the Sin[], and take the minus sign out. For example, try the following: In[1]:= Sin[b-a] Out[1]= -Sin[a-b] In[2]:= Cos[b-a] Out[2]= Cos[a-b] In[3]:= f[b-a] Out[3]= f[-a+b] Szabolcs