       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:=
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//FullForm=
Plus[Times[a, Cos[x]], Times[Power[a, 2], Sin[x]]]

Out//FullForm=
Plus[Times[Power[a, 2], Cos[x]], Times[-1, a, Sin[x]]]

Which tell us that we are seeing Out and Out displayed in
FullForm. This fits in with the fact that Out and Out themselves
do not involve FullForm, for example

In:=
%4
Out=
2
a  Cos[x] - a Sin[x]

(the mechanism is that FullForm is stripped off before Out is set)

However, with

In:=
fff2 = FullForm[f2[a,x]]

Out//FullForm=
Plus[Times[Power[a, 2], Cos[x]], Times[-1, a, Sin[x]]]

FullForm is  part of the stored value of fff2

In:=
?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:=
fff2
Out//FullForm=
Plus[Times[Power[a, 2], Cos[x]], Times[-1, a, Sin[x]]]

We can show that fff2 includes FullForm In:=
FullForm[fff2]

Out//FullForm=
FullForm[Plus[Times[Power[a, 2], Cos[x]],

Times[-1, a, Sin[x]]]]

and
In:=
Last[fff2]

Out=
2
a  Cos[x] - a Sin[x]

whereas

In:=
Last[%6]
Out=
-(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:=
FullForm[fff2 = f2[a,x]]

Out//FullForm=
Plus[Times[Power[a, 2], Cos[x]], Times[-1, a, Sin[x]]]

In:=
fff2

Out=
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

• Prev by Date: Re: Default format for new cells
• Next by Date: Re: Problem with sums differentiation
• Previous by thread: Re: "UnFullForm"ing an Expression?
• Next by thread: a system of equations and Solve[ ]