[Date Index]
[Thread Index]
[Author Index]
Re: Evaluation question
*To*: mathgroup at smc.vnet.net
*Subject*: [mg82219] Re: Evaluation question
*From*: Andrzej Kozlowski <akoz at mimuw.edu.pl>
*Date*: Mon, 15 Oct 2007 01:25:06 -0400 (EDT)
*References*: <200710120656.CAA04613@smc.vnet.net> <fepuqv$hvl$1@smc.vnet.net> <47109042.2000302@gmail.com> <AF26334E-9827-4055-8FEF-501F79F783AE@mimuw.edu.pl> <fesr61$pjb$1@smc.vnet.net> <4711F911.6050104@gmail.com>
I think this involves a rather subtle difference between an
expression and its value. (It is sometimes obscured by the fact that
soem expressions evaluate to themselves so are their own values). In
this case, it is the values of Plus that are considered numerical,
but values are obtianed after evaluation. The unevaluated expression
Plus[1,2] is not itself numerical.
Andrzej Kozlowski
On 14 Oct 2007, at 20:10, Szabolcs Horv=E1t wrote:
> Andrzej Kozlowski wrote:
>> On 14 Oct 2007, at 08:00, Andrzej Kozlowski wrote:
>>> Wihtout evaluation 1+2 is just a symbol and not the number 3 so
>>> NumericQ returns False.
>> I should have been more precise. Unevaluated 1+2 is an expression
>> (rather than a symbol); in fact it is the expression Plus[1,2],
>> which of course is not numeric. It's value is, of course, numeric, =
>> but that is obtained only after evaluation.
>
> But Plus has the attribute NumericFunction, therefore it should be
> considered "numerical" whenever all of its arguments are numerical.
>
> For example, see In[2] and In[3] below. f[1,2] stays unevaluated,
> but NumericQ[f[1,2]] still returns True because 'f' has the
> attribute NumericFunction, and all of its arguments (1 and 2) are
> numerical.
>
>>>> In[1]:= NumericQ[Unevaluated[1+2]]//Trace
>>>> Out[1]= {NumericQ[1+2],False}
>>>>
>>>> In[2]:= SetAttributes[f,NumericFunction]
>>>>
>>>> In[3]:= NumericQ[f[1,2]]//Trace
>>>> Out[3]= {NumericQ[f[1,2]],True}
>>>>
>>>> In[4]:= NumericQ[Unevaluated[f[1,2]]]//Trace
>>>> Out[4]= {NumericQ[f[1,2]],False}
>>>>
>>>
>>> I do not find this surprising. Wihtout evaluation 1+2 is just a
>>> symbol and not the number 3 so NumericQ returns False.
>>>
>
> --
> Szabolcs
Prev by Date:
**Re: Re: Re: Re: [Mathematica 6] Format->Magnification does notwork on notebook**
Next by Date:
**Re: Re: Hiding Input Cells**
Previous by thread:
**Re: Evaluation question**
Next by thread:
**Re: Evaluation question**
| |