MathGroup Archive 1997

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

Search the Archive

Re: NIntegrate with variable region

  • To: mathgroup at
  • Subject: [mg6287] Re: [mg6254] NIntegrate with variable region
  • From: Paul Abbott <paul at>
  • Date: Sat, 8 Mar 1997 00:26:07 -0500 (EST)
  • Organization: University of Western Australia
  • Sender: owner-wri-mathgroup at

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


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 

          God IS a weakly left-handed dice player

  • Prev by Date: Raster-Based Graphics
  • Next by Date: Re: y=f(t) vs t=f(y)
  • Previous by thread: NIntegrate with variable region
  • Next by thread: Re: Re: Windows front end