NIntegrate with variable region
- To: mathgroup at smc.vnet.net
- Subject: [mg6254] NIntegrate with variable region
- From: Zvi Wiener <mswiener at pluto.mscc.huji.ac.il>
- Date: Mon, 3 Mar 1997 01:29:07 -0500
- Organization: Hebrew University of Jerusalem
- Sender: owner-wri-mathgroup at wolfram.com
Dear Mathematica users, 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 have a much more complicated function which depends on parameters, but this example can demonstrate the problem. 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]] I have found a solution which I hardly understand, but it works. NIntegrate[ f[x],##]&@@{Prepend[lst, x]} Out[71]= 2.5 (Mathematica 3.0 with Windows 95) Can anybody explain to me why the first way did not work. I have a situation when the upper limit of integration is a variable and must be choosen automatically but then I have to adjust the region of integration since for different values of the upper limit there is a different number of singularities in the region. Zvi Wiener. *********************************************************************** Zvi Wiener Business School e-mail: mswiener at pluto.mscc.huji.ac.il Hebrew University office: 972-2-588-3049 Mount Scopus fax: 972-2-588-1341 Jerusalem 91905 http://pluto.huji.ac.il/~mswiener/zvi.html ISRAEL ***********************************************************************