MathGroup Archive 2006

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

Search the Archive

Re: x=2;Composition[f,FindMinimum][x+1,{x,a}]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg68343] Re: [mg68282] x=2;Composition[f,FindMinimum][x+1,{x,a}]
  • From: "Chris Chiasson" <chris at chiasson.name>
  • Date: Tue, 1 Aug 2006 07:00:23 -0400 (EDT)
  • References: <200607310745.DAA26874@smc.vnet.net> <44CDF8C9.3070607@wolfram.com> <acbec1a40607311814sf84582wcf4a6d608a0196f1@mail.gmail.com> <44CEBC60.1040406@wolfram.com>
  • Sender: owner-wri-mathgroup at wolfram.com

I was not aware that Composition[Hold,Hold] remains unevaluated. I
feel bad, because I was trying to use the fact that heads are
evaluated first to "wrap" FindMinimum -- in hindsight, it's obvious
that won't work. Thank you for your insight.

Thank you very much to the thread responders:
Leigh Pascoe
Jean-Marc Gulliet
Albert
Carl Woll
Janos Lobb

On 7/31/06, Carl K. Woll <carlw at wolfram.com> wrote:
> 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
> >>
> >
> >
>
>


-- 
http://chris.chiasson.name/


  • Prev by Date: Re: Using implicit information about row indices
  • Next by Date: Re: Using implicit information about row indices
  • Previous by thread: Re: x=2;Composition[f,FindMinimum][x+1,{x,a}]
  • Next by thread: Re: Using implicit information about row indices