Re: Integration of piecewise function
- To: mathgroup at smc.vnet.net
- Subject: [mg52486] Re: [mg52463] Integration of piecewise function
- From: Christopher Purcell <christopherpurcell at mac.com>
- Date: Mon, 29 Nov 2004 01:22:32 -0500 (EST)
- References: <200411280606.BAA06619@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Clear[X];
X[$B&X(B_ /; $B&X(B < 0] := 0;
X[$B&X(B_ /; 0 <= $B&X(B < 2] := 1;
X[$B&X(B_ /; 2 <= $B&X(B < 4] := -1 ;
X[$B&X(B_ /; 4<=$B&X(B] := 0 ;
NIntegrate[Evaluate[X[t]],{t,-Infinity,Infinity},WorkingPrecision->100]
returns an approximate zero (0.) and a warning that not enough
precision has been used.
The key "trick" is the Evaluate around the function.
A cleaner result comes with using the new Piecewise function in Version
5.1
Integrate[Piecewise[{{0, t < 0},{1,0 <= t < 2},{-1,2 <= t < 4},
{0,4<=t }}],{t,-Infinity,Infinity}]
This gives exactly 0 as expected.
Christopher Purcell
On Nov 28, 2004, at 2:06 AM, Riccardo wrote:
> X[\[Omega]_] := 0 /; \[Omega] < 0;
> X[\[Omega]_] := 1 /; 0 < \[Omega] < 2;
> X[\[Omega]_] := -1 /; 2 < \[Omega] < 4;
> X[\[Omega]_] := 0 /; \[Omega] > 4;
- References:
- Integration of piecewise function
- From: Riccardo <ricky@nospam.it>
- Integration of piecewise function