Re: Unevaluated

• To: mathgroup at smc.vnet.net
• Subject: [mg50657] Re: [mg50651] Unevaluated
• From: Andrzej Kozlowski <andrzej at akikoz.net>
• Date: Wed, 15 Sep 2004 07:54:28 -0400 (EDT)
• References: <200409150550.BAA11811@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```On 15 Sep 2004, at 14:50, Mike wrote:

>
> Not sure if this is a bug or just my lack of understanding of what of
> going
> on here:

The latter:
>
> In[1]= 2*Unevaluated[1+2]
>
> Out[1]= 2 Unevaluated[1+2]
>
> But
>
> In[2]= 1*Unevaluated[1+2]
>
> Out[2]= 3
>
> This is with V5.0.1 on Mac OS X 10.3.5
>
> Cheers
>
> Mike
>

The following happens:

First Unevaluated is striped off and Mathematica tries to evaluate
Times[2,1+2]. Since it does not know any rules that apply to such an
expression it simply restores back Unevaluated and you get
Times[2,Unevaluated[1+2]].

In the second case; first you get  Times[1,1+2] but now Mathematica
knows a rule that applies here, which is the rule that Times[1,a] is a
for every a whatever, so this rule is applied with 1+2 as a, returning
1+2. Unevaluated is now not restored since the expression has changed
so it is evaluated returning 3.

Using Unevaluated is tricky and requires a good understanding of the
Mathematica evaluator.

Andrzej Kozlowski
Chiba, Japan
http://www.akikoz.net/~andrzej/
http://www.mimuw.edu.pl/~akoz/

```

• References:
• Unevaluated
• From: Mike <m.HoneychurcNOSPAMh@uq.edu.au>
• Prev by Date: Re: MathML and WebMathematica
• Next by Date: Re: Simplify[ {Re[Sqrt[-1 + eta^2]], Im[Sqrt[-1 + eta^2]]}, eta<1]