MathGroup Archive 2011

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

Search the Archive

Re: Just another Mathematica "Gotcha"

  • To: mathgroup at smc.vnet.net
  • Subject: [mg120798] Re: Just another Mathematica "Gotcha"
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Thu, 11 Aug 2011 05:10:04 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201108091119.HAA15770@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

No reading or experimentation is necessary.

When I wonder what operator has higher precedence -- as I often do -- I  
double-click on each operator in turn, and automatic selection expansion  
tells me what I need to know.

Bobby

On Wed, 10 Aug 2011 05:46:13 -0500, Murray Eisenberg  
<murray at math.umass.edu> wrote:

> 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....
>


-- 
DrMajorBob at yahoo.com




  • Prev by Date: Re: Feature idea (may already be there)
  • Next by Date: Re: am I correctly perceiving a weakness in FinancialDerivative[] ?
  • Previous by thread: Re: Just another Mathematica "Gotcha"
  • Next by thread: Re: Just another Mathematica "Gotcha"