MathGroup Archive 2006

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

Search the Archive

Re: variable of integration not localized in Integrate and Sum?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg63836] Re: [mg63827] variable of integration not localized in Integrate and Sum?
  • From: Pratik Desai <pdesai1 at umbc.edu>
  • Date: Wed, 18 Jan 2006 02:39:05 -0500 (EST)
  • References: <200601170933.EAA07428@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Don Hatch wrote:

>Apparently I need to explicitly localize t in the following,
>otherwise it messes up when I pass in t as the second argument.
>    In:
>        F[f_, x_] := Integrate[f[x + t], {t, -1/2, 1/2}]
>        F[Sin, x]
>        F[Sin, t]
>    Out:
>        2 Sin[1/2] Sin[x]  <---- correct
>        0                  <---- ?!?!
>  
>
This works, when you say you want to integrate with respect to t on your 
RHS, you loose all of your control over changing the variable you 
integrate over in your function definition
  In[23]:=
Clear[f,F,x,r]
   F[f_,r_] := Integrate[f[x + t], {r, -1/2, 1/2}]
F[Sin,t]
F[Sin,x]

Out[25]=
\!\(2\ Sin[1\/2]\ Sin[x]\)

Out[26]=
\!\(2\ Sin[1\/2]\ Sin[t]\)

>This is surprising to me-- I thought that
>the fact that t is the integration variable
>would cause it to be automatically localized, but apparently not.
>To get the right answer, I can say:
>    In:
>        F[f_, x_] := Module[{t}, Integrate[f[x + t], {t, -1/2, 1/2}]]
>        F[Sin, x]
>        F[Sin, t]
>    Out:
>        2 Sin[1/2] Sin[x]  <---- correct
>        2 Sin[1/2] Sin[t]  <---- correct
>(note, I really have to use Module, not Block-- it still messes up using
>Block).
>
>The documentation for Integrate doesn't seem to support my hope that t gets
>localized, as far as I could see;
>however, note that exactly the same problem
>occurs for Sum, whose documentation does explicitly state:
>   The iteration variable i is treated as local.
>So here is an example that seems to clearly contradict the documentation
>of Sum:
>   In:
>       F[f_, x_] := Sum[f[x + t], {t, -1/2, 1/2, 1/10}]/11
>       F[Identity, x]
>       F[Identity, t]
>   Out:
>       x              <---- correct
>       0              <---- ?!?!
>Just as for Integrate, it works properly when I explicitly
>localize using Module (but not Block):
>   In:
>       F[f_, x_] := Module[{t}, Sum[f[x + t], {t, -1/2, 1/2, 1/10}]/11]
>       F[Identity, x]
>       F[Identity, t]
>   Out:
>       x              <---- correct
>       t              <---- correct
>
>Is this a bug in Sum and/or Integrate?
>I'm using Mathematica version 5.2.0.0, on Linux/X.
>
>Don Hatch
>
>  
>


  • Prev by Date: Getting identifier names from content MathML of equation
  • Next by Date: Re: Java -> Mathematica -> Java
  • Previous by thread: Getting identifier names from content MathML of equation
  • Next by thread: Re: variable of integration not localized in Integrate and Sum?