Re: x=2;Composition[f,FindMinimum][x+1,{x,a}]
- To: mathgroup at smc.vnet.net
- Subject: [mg68327] Re: [mg68282] x=2;Composition[f,FindMinimum][x+1,{x,a}]
- From: "Carl K. Woll" <carlw at wolfram.com>
- Date: Tue, 1 Aug 2006 06:59:58 -0400 (EDT)
- References: <200607310745.DAA26874@smc.vnet.net> <44CDF8C9.3070607@wolfram.com> <acbec1a40607311814sf84582wcf4a6d608a0196f1@mail.gmail.com>
- Sender: owner-wri-mathgroup at wolfram.com
Chris Chiasson wrote: > The crash confused matters for me. Thank you for clearing that up. Now > that the source is known, perhaps someone could crack the "original" > question I am trying to solve: > > x=2;{Composition[Hold][x+1,{x,a}],Composition[Hold,Hold][x+1,{x,a}]} > > produces > > {Hold[x+1,{x,a}],Hold[Hold[3,{2,a}]]} > > Why is it that in Composition[Hold], Composition does not effectively > block the HoldAll attribute of Hold? The same thing happens with > Identity. > It's because Mathematica evaluates the head first and then the body. In the first case the head evaluates to Hold: In[3]:= Composition[Hold] Out[3]= Hold So, Composition[Hold][x+1,{x,a}] ---> Hold[x+1,{x,a}] and Mathematica doesn't evaluate the body because of the Hold. In the second case the head doesn't evaluate to anything: In[4]:= Composition[Hold, Hold] Out[4]= Composition[Hold,Hold] So, the body gets evaluated, and then the Composition takes place Composition[Hold,Hold][x+1,{x,a}] ---> Composition[Hold,Hold][3,{2,a}] ---> Hold[Hold[3,{2,a}]] This can be seen by looking at the Trace. Carl Woll Wolfram Research > On 7/31/06, Carl K. Woll <carlw at wolfram.com> wrote: >> Chris Chiasson wrote: >> > The above command crashes my kernel on Windows XP and Linux. Anybody >> else? >> > >> >> The crash comes when evaluating >> >> FindMinimum[3,{2,a}] >> >> Presumably you did not intend to evaluate this. >> >> In the development version, the above code does not cause a crash. >> >> Carl Woll >> Wolfram Research >> > >