Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #4283

Re: Just another Mathematica "Gotcha"

From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Just another Mathematica "Gotcha"
Date 2011-08-10 10:57 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j1to67$psu$1@smc.vnet.net> (permalink)

Show all headers | View raw


On 8/9/11 at 7:19 AM, siegman@stanford.edu (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.

If and only if the // and /. operators had the same precedence
this would be true. But since /. has higher precedence than //

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

is equivalent to

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

rather thab

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

The problem here is exactly analogous to why

a + b * c

doesn't yield (a+b)*c

>2)  This is just another Mathematica "Gotcha" -- and not a
>particularly forgivable one.

No, this is simply a failure on your part to understand operator precedence.


Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Just another Mathematica "Gotcha" Bill Rowe <readnews@sbcglobal.net> - 2011-08-10 10:57 +0000

csiph-web