Re: NIntegrate with variable region
- To: mathgroup at smc.vnet.net
- Subject: [mg6287] Re: [mg6254] NIntegrate with variable region
- From: Paul Abbott <paul at physics.uwa.edu.au>
- Date: Sat, 8 Mar 1997 00:26:07 -0500 (EST)
- Organization: University of Western Australia
- Sender: owner-wri-mathgroup at wolfram.com
Zvi Wiener wrote:
> I wish to take an indefinite integral of a piecewise
> continuous function. For example:
>
> f[x_]:= Which[ x<0, 0, x<1, 1, x>=1, x];
>
> I tried:
> lst = {-1,0,1,2};
> NIntegrate[ f[x], Prepend[lst,x]]
>
> But the result was:
>
> NIntegrate::vars:
> Integration range specification Prepend[lst, x]
> is not of the form {x, xmin, ..., xmax}.
>
> NIntegrate[f[x], Prepend[lst, x]]
Prepend[lst,x] is not evaluated because
In[3]:= Attributes[NIntegrate]
Out[3]= {HoldAll,Protected}
You need to evaluate the Integration range:
In[4]:= NIntegrate[ f[x], Evaluate[Prepend[lst,x]]]
Out[4]= 2.5
Cheers,
Paul
_________________________________________________________________
Paul Abbott
Department of Physics Phone: +61-9-380-2734
The University of Western Australia Fax: +61-9-380-1014
Nedlands WA 6907 paul at physics.uwa.edu.au
AUSTRALIA http://www.pd.uwa.edu.au/Paul
God IS a weakly left-handed dice player
_________________________________________________________________