MathGroup Archive 2009

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

Search the Archive

Re: HoldAll for Integrate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98069] Re: HoldAll for Integrate
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Sun, 29 Mar 2009 02:46:19 -0500 (EST)
  • References: <gqfknb$kht$1@smc.vnet.net> <gqia4g$oi0$1@smc.vnet.net> <gqkuoj$44r$1@smc.vnet.net>

Hi,

AFAIK Integrate[] is C/C++ code of the Mathematica Kernel
and only the CVS at Wolfram Reseach will know exacly
what have changed since 1996.

Regards
   Jens

Tammo Jan Dijkema wrote:
> Hi,
> 
> Thanks for the responses. I realize that I'm doing a strange thing 
> here, the goal is not to compute the integral, but to understand a bit 
> better how Integrate works with regards to evaluation orders.
> 
> I hadn't tried using Trace, and for the indefinite integral it 
> certainly explains the output 1000. Apparently, something in the code 
> for Integrate has changed since 1996 and now (since it evaluated to 
> 1000/3 then).
> 
> However, I'm still curious about the output of the definite integral 
> Integrate[ x^2, {x,0,1} ]
> There is no 'reasonable' way I can think of for this to yield the value 0.
> 
> Regards,
> Tammo Jan
> 
> Op 2009-03-27 11:34:56 +0100, zei Jens-Peer Kuska 
> <kuska at informatik.uni-leipzig.de>:
> 
>> Hi,
>>
>> compare
>> x = 10;
>> SetAttributes[Integrate, HoldAll];
>>
>> Trace[Block[{x}, Integrate[x^2, x]]]
>>
>> with
>>
>> Trace[Integrate[x^2, x]]
>>
>> and you see, that x^2 is evaluated to 100 but
>> x is preserved, than 100 dx is computed to 100*x
>> and than x->10 is substituted again to give
>> 1000
>>
>> Regards
>>    Jens
>>
>> Tammo Jan Dijkema wrote:
>>> The following commands yield unexpected output:
>>>
>>> x=10;
>>> Integrate[x^2, {x,0,1}]
>>>
>>> That is because Integrate does not have attributes HoldAll, so that the
>>> second command will be interpreted as Integrate[100, {10,0,1}] which is
>>> not a command that Integrate can work with (so a warning message is
>>> returned).
>>>
>>> However, I can add the attribute HoldAll to Integrate myself:
>>>
>>> SetAttributes[Integrate, HoldAll];
>>>
>>> I'm not very sure what to expect when now trying the same experiment
>>> (the correct answer 1/3 would be nice), but the actual output surprised
>>> me:
>>>
>>> x=10;
>>> Integrate[x^2, {x,0,1}]
>>>
>>> Yields as output: 0 (without any warnings). Could anyone explain why I
>>> should have expected this result?
>>>
>>> On a side note, I found a similar in the Tech Support column of the
>>> Mathematica Journal Volume 6, Issue 2, by Carl Roy. He tried the
>>> integral without limits:
>>>
>>> x=10;
>>> SetAttributes[Integrate, HoldAll];
>>> Integrate[x^2, x]
>>>
>>> In the journal, the output 1000/3 is mentioned, whereas in Mathematica
>>> 7.0.1 this outputs 1000.
>>>
>>> Again, does anyone understand this?
> 
> 


  • Prev by Date: Re: Option instead of a function argument: is it possible?
  • Next by Date: Re: rules on vector sequence
  • Previous by thread: Re: HoldAll for Integrate
  • Next by thread: Re: HoldAll for Integrate