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


Groups > comp.soft-sys.math.mathematica > #4270 > unrolled thread

Re: Just another Mathematica "Gotcha"

Started byMurray Eisenberg <murray@math.umass.edu>
First post2011-08-10 10:49 +0000
Last post2011-08-10 10:49 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Just another Mathematica "Gotcha" Murray Eisenberg <murray@math.umass.edu> - 2011-08-10 10:49 +0000

#4270 — Re: Just another Mathematica "Gotcha"

FromMurray Eisenberg <murray@math.umass.edu>
Date2011-08-10 10:49 +0000
SubjectRe: Just another Mathematica "Gotcha"
Message-ID<j1tnog$pn4$1@smc.vnet.net>
There you go again, insinuating that something is wrong with Mathematica 
when it's just something you don't understand (or simply just don't 
like). And ratcheting up the rhetoric with language such as "by any 
normal rules of interpretation or ordinary interpretations".

If you really do want to understand what's going on here, you could take 
a moment to experiment or read the documentation and treat it as a 
"teachable moment".

You could try something simpler, e.g.:

   expr = a + b x;
   expr // f /. b -> 0
   expr /. b -> 0 // f

Or look at the FullForms of the latter two expressions (after wrapping 
each in Hold).

Or try forcing the order of precedence with the first expression:

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

Or search the Documentation Center for "order of precedence", say, and 
in the first hit peruse the table documenting order of precedence in 
tutorial/OperatorInputForms.

Yes, there are dangers in deviating from straightforward head[[expr]] 
syntax. You can either stick with that or else learn what you need to 
know to avoid, or at least deal with, any surprises.

On 8/9/11 7:19 AM, 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....

-- 
Murray Eisenberg                     murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web