MathGroup Archive 2011

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

Search the Archive

Re: Just another Mathematica "Gotcha"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg120780] Re: Just another Mathematica "Gotcha"
  • From: David Bailey <dave at removedbailey.co.uk>
  • Date: Wed, 10 Aug 2011 06:44:45 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j1r5d3$fi4$1@smc.vnet.net>

On 09/08/2011 12:24, AES wrote:
> Seems as if the following two expression should yield the same output
> -- seems that way to me anyway -- but they don't.  I'll hide the
> actual outputs down below so Mathematica gurus (or "ordinary users")
> can make their predictions as to which one does what.
>
> In[1]:= Series[a+(b1+b2)x,{x,0,1}] //Normal /.{b2->0}
>
> In[2]:= Series[a+(b1+b2)x,{x,0,1}] /.{b2->0} //Normal
>
My conclusion is that you have simply ignored the precedence of the 
various operators:

Series[a+(b1+b2)x,{x,0,1}]//Normal/.{b2->0}//Hold//FullForm

Hold[ReplaceAll[Normal,List[Rule[b2,0]]][Series[Plus[a,Times[Plus[b1,b2],x]],List[x,0,1]]]]

I don't know how you think the Mathematica language should be changed to 
avoid mistakes of this sort, but of course, you do not need to use a 
single operator in your code if you prefer!

David Bailey
http://www.dbaileyconsultancy.co.uk





  • Prev by Date: Re: More robust pattern based replacement rules?
  • Next by Date: Re: Just another Mathematica "Gotcha"
  • Previous by thread: Re: Just another Mathematica "Gotcha"
  • Next by thread: Re: Just another Mathematica "Gotcha"