MathGroup Archive 1993

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

Search the Archive

Re: Hold/Evaluate in Integrate


<<
    Can anyone tell me why

Hold[Integrate[Evaluate[x+x], x]]

returns

Hold[Integrate[Evaluate[x+x],x]]

not Hold[Integrate[2x, x]]?
>>

Probably for the same reason that
	Hold[2+Evaluate[2+2]]
returns
	Hold[2+Evaluate[2+2]]
and not
	Hold[2+4]

It would appear that Evaluate *only* applies to the function it appears
in.  Integrate does not have attributes Hold, HoldFirst, or HoldRest,
so use of Evaluate with Integrate won't make a difference.  Anyway,
since there is an outer hold on the entire expression, the Evaluate
makes no difference and is 'buried'.

Here's a simple workaround -- call the function IntegrateEvaluated,
shown below, which has exactly the same syntax as Integrate (and all
options), but will cause the first argument to be evaluated:

	Attributes[IntegrateEvaluated] := {HoldRest};
	IntegrateEvaluated[func_,rest__] :=
		Hold[Integrate[func,rest]];

With the definition above, you'll get what you want:

	In[1]:= IntegrateEvaluated[x+x,x]
	Out[1]= Hold[Integrate[2 x, x]]


 \\|//                         "Television is a medium -- it is
  - -                           neither rare nor well done."
  o o                                            -- Ernie Kovacs
   J   roberto sierra
   O   tempered microdesigns    NOTICE:
  \_/  san francisco, ca        The ideas and opinions expressed
       bert at netcom.com          herein are not those of the author.





  • Prev by Date: **nb2tex
  • Next by Date: Public Domain Software on Solaris 2.X
  • Previous by thread: **nb2tex
  • Next by thread: Re: Hold/Evaluate in Integrate