Re: Just another Mathematica "Gotcha"

• To: mathgroup at smc.vnet.net
• Subject: [mg120781] Re: Just another Mathematica "Gotcha"
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Wed, 10 Aug 2011 06:44:56 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <201108091119.HAA15770@smc.vnet.net>

```It's just a question of the order of precedence. If you are not sure,
either use brackets:

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

a+b1 x

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

a+b1 x

or don't use the Postfix form at all:

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

a+b1 x

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

a+b1 x

You are obviously exceptionally talented in created your own "Gotchas".

Andrzej Kozlowski

On 9 Aug 2011, at 13:19, 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 conclusions:
>
> 1)  By any normal rules of interpretation or ordinary interpretations
> of these statements, they both should do the same same thing.
>
> 2)  This is just another Mathematica "Gotcha" -- and not a
> particularly forgivable one.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Out[1]= a+(b1+b2) x
>
> Out[2]= a+b1 x
>

```

• Prev by Date: Re: Just another Mathematica "Gotcha"
• Next by Date: Re: Some questions about a Mathematica script
• Previous by thread: Re: Just another Mathematica "Gotcha"
• Next by thread: Re: Just another Mathematica "Gotcha"