Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: Mistake in applying a rule

  • To: mathgroup at smc.vnet.net
  • Subject: [mg80681] Re: Mistake in applying a rule
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Tue, 28 Aug 2007 06:43:37 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <fb0f17$f05$1@smc.vnet.net>

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