MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Mistake in applying a rule


Steven Siew wrote:

>   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.

<snip>

Mathematica reorders the expressions in canonical order before 
evaluating them. Also, evaluated expressions are returned in canonical 
order too. For instance,

In[1]:= {x^2 + x + a, Cos[x - a], Sin[x - a]}

Out[1]= {a + x + x^2, Cos[a - x], -Sin[a - x]}

To keep the elements of an expression in a specific (user-defined) 
order, you can use *HoldForm* as in

In[2]:= Simplify[Integrate[Cos[x - a], x]] /. -Sin[(g_) - (h_)] ->
      HoldForm @ Sin[h - g]

Out[2]= Sin[x - a]

HTH,
-- 
Jean-Marc


  • Prev by Date: Re: Global Variables in Options?
  • Next by Date: Re: Plot "not working"
  • Previous by thread: Re: Mistake in applying a rule
  • Next by thread: Re: Mistake in applying a rule