Re: "UnFullForm"ing an Expression?
- To: mathgroup at smc.vnet.net
- Subject: [mg13271] Re: "UnFullForm"ing an Expression?
- From: "Allan Hayes" <hay at haystack.demon.cc.uk>
- Date: Fri, 17 Jul 1998 03:18:05 -0400
- References: <6ocrqt$h03@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
AES wrote in message <6ocrqt$h03 at smc.vnet.net>... >I recently posted a query noting that if you enter the following > > f1[a_,x_] :=a Cos[x] + a^2 Sin[x] > > f2[a_,x_] := D[f1[a,x],x] > >you can make a Table[ ] of f1[a,x] but not of f2[a,x]. > >If I look at the FullForms for these, e.g. > > f1[a,x] // FullForm > > f2[a,x] // FullForm > >they both look like simple functions to me (i.e., f2[a,x] shows no >visible memory of having originated from a derivative), except the f2 >is inside a "FullForm[ ]" wrapper and f1 isn't. > >Is there a way to "UnFillForm" f2 ? If so, would f2 from then on act >like f1 ? Does this query make any sense? > >I'd like to understand the situation here. > >Thanks siegman at ee.stanford.edu > I get In[1]:= f1[a_,x_] :=a Cos[x] + a^2 Sin[x] f2[a_,x_] := D[f1[a,x],x] f1[a,x] // FullForm f2[a,x] // FullForm Out[3]//FullForm= Plus[Times[a, Cos[x]], Times[Power[a, 2], Sin[x]]] Out[4]//FullForm= Plus[Times[Power[a, 2], Cos[x]], Times[-1, a, Sin[x]]] Which tell us that we are seeing Out[3] and Out[4] displayed in FullForm. This fits in with the fact that Out[3] and Out[4] themselves do not involve FullForm, for example In[5]:= %4 Out[5]= 2 a Cos[x] - a Sin[x] (the mechanism is that FullForm is stripped off before Out[4] is set) However, with In[6]:= fff2 = FullForm[f2[a,x]] Out[6]//FullForm= Plus[Times[Power[a, 2], Cos[x]], Times[-1, a, Sin[x]]] FullForm is part of the stored value of fff2 In[7]:= ?fff2 Global`fff2 fff2 = FullForm[a^2*Cos[x] - a*Sin[x]] So, evaluating fff2 gives the same as evaluating FullForm[a^2*Cos[x] - a*Sin[x]] In[8]:= fff2 Out[8]//FullForm= Plus[Times[Power[a, 2], Cos[x]], Times[-1, a, Sin[x]]] We can show that fff2 includes FullForm In[9]:= FullForm[fff2] Out[9]//FullForm= FullForm[Plus[Times[Power[a, 2], Cos[x]], Times[-1, a, Sin[x]]]] and In[10]:= Last[fff2] Out[10]= 2 a Cos[x] - a Sin[x] whereas In[11]:= Last[%6] Out[11]= -(a Sin[x]) A variant of the above that lets us see the FullForm without including FullForm in the stored value of fff2 is In[12]:= FullForm[fff2 = f2[a,x]] Out[12]//FullForm= Plus[Times[Power[a, 2], Cos[x]], Times[-1, a, Sin[x]]] In[13]:= fff2 Out[13]= 2 a Cos[x] - a Sin[x] ------------------------------------------------------------- Allan Hayes Training and Consulting Leicester UK http://www.haystack.demon.co.uk hay at haystack.demon.co.uk voice: +44 (0)116 271 4198 fax: +44(0)116 271 8642