Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Mathematica language issues

  • To: mathgroup at
  • Subject: [mg53032] Re: Mathematica language issues
  • From: David Bailey <dave at>
  • Date: Mon, 20 Dec 2004 06:35:13 -0500 (EST)
  • References: <> <cq0tm1$2m2$> <cq3p4m$hs8$>
  • Sender: owner-wri-mathgroup at

Maxim wrote:
> On Sat, 18 Dec 2004 09:36:01 +0000 (UTC), Andrzej Kozlowski  
> <akoz at> wrote:
>>On 17 Dec 2004, at 19:20, Maxim wrote:
>>>Unevaluated[1 + 1]*2
>>>2*Unevaluated[1 + 1]
>>>2*Unevaluated[1 + 1]
>>This is not a glitch but works exactly as one woudl expect.  You can
>>see the difference and the reason by looking at Trace in both cases
>>(although there is no need for that, if you understand Unevaluated you
>>can see it right away).
>>{2 (1+1),2 Unevaluated[1+1]}
>>First Unevaluated is stipped away and Mathematica attempts ot evaluate
>>2*(1+1). Since it knows no rule to apply and the expression has not
>>changed Unevaluated is restored and evaluation is completed with the
>>output you see.
>>{(1+1) 2,2 (1+1),{1+1,2},2 2,4}
>>As before, first Unevaluated is stripped away and Mathematica tires to
>>evaluate 2*(1+1). It now knows a rule to apply, which is given by the
>>Orderless attribute and the canonical ordering, so it converts the
>>expression into the form 2 (1+1). But now Unevaluated is not restored
>>because the expression has changed so evaluation continues with 1+1
>>evaluationg to 2 and finally you obtain 4.
>>Now, I have honstly considered this case only because I could see at
>>once what what was going on. I do not knwo if any of the others are
>>glitches but jusdging by my experience with the past "language
>>glitches" you have reported (unlike the more serious problems desribed
>>in your last posting) I rather doubt it. However I have no time to
>>spend on this just to prove a point (again).
>>Andrzej Kozlowski
>>Chiba, Japan
> I do not agree. Suppose we evaluate z*Unevaluated[1 + 1]; according to  
> your explanation, after the reordering of the factors Unevaluated should  
> disappear from the final result. However, the expression evaluates to  
> Unevaluated[1 + 1]*z. Further, suppose we take Unevaluated[1  
> + 1]*Sin[Pi/4]: Sin[Pi/4] evaluates to 1/Sqrt[2], so in this case an  
> evaluation step definitely takes place; however, the output is  
> Unevaluated[1 + 1]/Sqrt[2]. Your theory simply doesn't work. But even if  
> it did, there is another problem: suppose I use Sin[Pi/8] instead of  
> Sin[Pi/4] -- then first you would need to know whether Mathematica has a  
> built-in rule for Sin[Pi/8] to arrive at any conclusion as to how it might  
> work with Unevaluated (that is, what will count as an evaluation step?).  
> So to apply your explanation we would have to search through all the  
> built-in rules of Mathematica.
> Maxim Rytin
> m.r at

Unevaluated does indeed seem inconsistent. Consider the following tests:






I suppose my only objection to your original post is the implication 
that the glitches that you report are a really big deal - I mean people 
DO use Mathematica successfully in all sorts of research!

The other thing to remember here is that it can be very dangerous to 
change things like this - because you can break existing code that 
relies on such quirks - probably by mistake.

David Bailey

  • Prev by Date: Re: Minors
  • Next by Date: Re: Re: Re: Mathematica slows down
  • Previous by thread: Re: Re: Mathematica language issues
  • Next by thread: Re: Mathematica language issues