Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Re: Symbol and Pi and expressions evaluating to Pi

  • To: mathgroup at smc.vnet.net
  • Subject: [mg70143] Re: Symbol and Pi and expressions evaluating to Pi
  • From: albert <awnl at arcor.de>
  • Date: Thu, 5 Oct 2006 03:32:56 -0400 (EDT)
  • References: <eg0286$818$1@smc.vnet.net>

David Bakin wrote:

> [I apologize if this question has been asked - as it surely must have
> been already - my searches didn't get me to the answer in the
> archives.  You can send me some better search terms and I'll be happy
> with that as an answer, thanks!]

questions like this are indeed asked every now and then, the key to a better
understanding is to read the mathematica book section 2.5 'The evaluation
of expressions'.

> The Mathematica 5.1 help browser entry for Symbol under "Further Examples"
> defines a function SymbolQ1 to determine if something is a Symbol as
> follows:
> 
> Attributes[SymbolQ1] = {HoldAllComplete};

Note the attribute HoldAllComplete of SymbolQ1, it is the explanation for
your question...

> SymbolQ1[expr_] := AtomQ@Unevaluated[expr] &&
> Head@Unevaluated[expr]===Symbol
> 
> Then it shows the following:
> 
>      In:= SymbolQ[Pi]
>      Out= True
>      In:= {a definite integral evaluating to Pi} == Pi
>      Out= True
>      In:= SymbolQ[that definite integral]
>      Out= False
> 
> Yet FullForm[Pi] is the same as FullForm[that definite integral], and is
> Pi.

FullForm does not have any of the Hold-Attributes, so before it will show
the full form of its arguments, it will evaluate them, and if the definite
integral happens to evaluate to Pi, this is what is returned.

> So I have two questions:
> 1) Why isn't SymbolQ[that definite integral] == True?  What is it if
> it isn't a Symbol?

due to the HoldAllComplete-Attribute and the explicit wrapping with
Unevaluated, the definite Integral is not evaluated before AtomQ looks at
it, and since it is an expression AtomQ will return False. You might gain
some understanding when evaluating the following lines:

Integrate[x,{x,0,1}]

Unevaluated[Integrate[x,{x,0,1}]]

Print[Integrate[x,{x,0,1}]]

Print[Unevaluated[Integrate[x,{x,0,1}]]]

AtomQ[Integrate[x,{x,0,1}]]

AtomQ[Unevaluated[Integrate[x,{x,0,1}]]]

Note, that Unevaluated also has the Attribute HoldAllComplete!

> 2) Why are FullForm[Pi] and FullForm[that definite integral] different?

the result of both are the same in your case, but  FullForm[that definite
integral] will first evaluate the integral to find the result Pi. You can
look at what happens with e.g.

TracePrint[ FullForm[that definite integral] ]

and compare that to

TracePrint[ FullForm[ Pi ]]

hth,

albert


  • Prev by Date: Re: Symbol and Pi and expressions evaluating to Pi
  • Next by Date: FrameTicks
  • Previous by thread: Re: Symbol and Pi and expressions evaluating to Pi
  • Next by thread: Program to add continued fractions with polynomial partial quotients