Discussion:
Integral of Piecewise function involving DiracDelta
(too old to reply)
Andrew Moylan
2007-04-04 08:17:28 UTC
Permalink
Here is an integral that I expect Mathematica to evaluate to 1:

Integrate[Piecewise[{{DiracDelta[x], -1 < x < 1}}, 0],
{x, -Infinity, Infinity}]

However, Mathematica 5.2 (Windows) gives the answer as 0. Here's a
similar integral that I also expect to evaluate to 1:

Integrate[Piecewise[{{DiracDelta[x-1/2], -1 < x < 1}}, 0],
{x, -Infinity, Infinity}]

For this integral, Mathematica doesn't return 0. It returns the
following:

Integrate[Piecewise[{{2*DiracDelta[-1 + 2*x], -1 < x < 1}},
0], {x, -Infinity, Infinity}]

Can anyone help me understand what's happening here?

Cheers,

Andrew
dimitris
2007-04-05 08:10:11 UTC
Permalink
For integrals like yours I would strongly suggest the
PiecewiseIntegrare function
by Maxim Rytin available from here:

http://library.wolfram.com/infocenter/MathSource/5117/

After loading the package, we get

In[54]:=
PiecewiseIntegrate[Piecewise[{{DiracDelta[x], -1 < x < 1}}, 0], {x, -
Infinity, Infinity}]
Out[54]=
1

In[55]:=
PiecewiseIntegrate[Piecewise[{{DiracDelta[x - 1/2], -1 < x < 1}}, 0],
{x, -Infinity, Infinity}]
Out[55]=
1

In the above mentioned notebook there many examples that demonstrates
PiecewiseIntegrate
capabilities.

Regards
Dimitris
Post by Andrew Moylan
Integrate[Piecewise[{{DiracDelta[x], -1 < x < 1}}, 0],
{x, -Infinity, Infinity}]
However, Mathematica 5.2 (Windows) gives the answer as 0. Here's a
Integrate[Piecewise[{{DiracDelta[x-1/2], -1 < x < 1}}, 0],
{x, -Infinity, Infinity}]
For this integral, Mathematica doesn't return 0. It returns the
Integrate[Piecewise[{{2*DiracDelta[-1 + 2*x], -1 < x < 1}},
0], {x, -Infinity, Infinity}]
Can anyone help me understand what's happening here?
Cheers,
Andrew
Jean-Marc Gulliet
2007-04-05 08:14:16 UTC
Permalink
Post by Andrew Moylan
Integrate[Piecewise[{{DiracDelta[x], -1 < x < 1}}, 0],
{x, -Infinity, Infinity}]
However, Mathematica 5.2 (Windows) gives the answer as 0. Here's a
Integrate[Piecewise[{{DiracDelta[x-1/2], -1 < x < 1}}, 0],
{x, -Infinity, Infinity}]
For this integral, Mathematica doesn't return 0. It returns the
Integrate[Piecewise[{{2*DiracDelta[-1 + 2*x], -1 < x < 1}},
0], {x, -Infinity, Infinity}]
Can anyone help me understand what's happening here?
Cheers,
Andrew
Many, if not all, of the answers are in Maxim Rytin's notebook titled "
Integration of Piecewise Functions with Applications" available at

http://library.wolfram.com/infocenter/MathSource/5117/

"The notebook contains the implementation of four functions
PiecewiseIntegrate, PiecewiseSum, NPiecewiseIntegrate, NPiecewiseSum.
They are intended for working with piecewise continuous functions, and
also generalized functions in the case of PiecewiseIntegrate. They
support all the standard Mathematica piecewise functions such as
UnitStep, Abs, Max, as well as Floor and other arithmetic piecewise
functions. PiecewiseIntegrate supports the multidimensional DiracDelta
function and its derivatives. The arguments of the piecewise functions
can be non-algebraic and contain symbolic parameters."

For instance,

PiecewiseIntegrate[Piecewise[
{{DiracDelta[x], -1 < x < 1}}, 0],
{x, -Infinity, Infinity}]

returns 1, and

PiecewiseIntegrate[Piecewise[
{{DiracDelta[x - 1/2], -1 < x < 1}}, 0],
{x, -Infinity, Infinity}]

returns 1

Regards,
Jean-Marc
Michael Weyrauch
2007-04-05 08:27:40 UTC
Permalink
Hello,

well in answering this question one could quote the documentation, which under "Numerical Functions"
says that "Piecewise represents piecewise functions". And DiracDelta is not a function.

So for me Piecewise and DiracDelta don't go together mathematically well. I would suggest
to put the different integration intervals into the integration limits and NOT use Piecewise
together with a distribution like DiracDelta. Thats also mathematically more sensible, I believe.

Maybe Mathematica should rather issue a warning like "Don't do things like that" rather that returning a questionable
result.

Regards, Michael Weyrauch
Post by Andrew Moylan
Integrate[Piecewise[{{DiracDelta[x], -1 < x < 1}}, 0],
{x, -Infinity, Infinity}]
However, Mathematica 5.2 (Windows) gives the answer as 0. Here's a
Integrate[Piecewise[{{DiracDelta[x-1/2], -1 < x < 1}}, 0],
{x, -Infinity, Infinity}]
For this integral, Mathematica doesn't return 0. It returns the
Integrate[Piecewise[{{2*DiracDelta[-1 + 2*x], -1 < x < 1}},
0], {x, -Infinity, Infinity}]
Can anyone help me understand what's happening here?
Cheers,
Andrew
dh
2007-04-05 08:29:41 UTC
Permalink
Hi Andrew,

Obviously there is a bug in the implementation of Pieceweise or its

integral. Also note that:

Integrate[Piecewise[{{DiracDelta[x],-1<x<1}},0],{x,-.1,.1}] evaluates to 1.

Further, concerning your second question. It is well known that

DiracDelta[a x] == DiracDelta[x] / a for a constant a>0. A handwaving

argument is, that the dirac function becomes "narrower" by a factor of

a, what makes the integral smaller by the same factor.

Daniel
Post by Andrew Moylan
Integrate[Piecewise[{{DiracDelta[x], -1 < x < 1}}, 0],
{x, -Infinity, Infinity}]
However, Mathematica 5.2 (Windows) gives the answer as 0. Here's a
Integrate[Piecewise[{{DiracDelta[x-1/2], -1 < x < 1}}, 0],
{x, -Infinity, Infinity}]
For this integral, Mathematica doesn't return 0. It returns the
Integrate[Piecewise[{{2*DiracDelta[-1 + 2*x], -1 < x < 1}},
0], {x, -Infinity, Infinity}]
Can anyone help me understand what's happening here?
Cheers,
Andrew
Bob Hanlon
2007-04-05 08:31:42 UTC
Permalink
The problem appears to be with the compound inequality.

Works if you use (-1 < x || x < 1) vice (-1 < x < 1)

$Version

5.2 for Mac OS X (June 20, 2005)

Integrate[DiracDelta[x],{x,-Infinity,Infinity}]

1

Integrate[DiracDelta[x],{x,-1,1}]

1

Integrate[Piecewise[{{DiracDelta[x], -1 < x || x < 1}}, 0],
{x, -Infinity, Infinity}]

1

Integrate[DiracDelta[x-1/2],{x,-Infinity,Infinity}]

1

Integrate[DiracDelta[x-1/2],{x,-1,1}]

1

Integrate[Piecewise[{{DiracDelta[x - 1/2], -1 < x || x < 1}}, 0],
{x, -Infinity, Infinity}]

1


Bob Hanlon
Post by Andrew Moylan
Integrate[Piecewise[{{DiracDelta[x], -1 < x < 1}}, 0],
{x, -Infinity, Infinity}]
However, Mathematica 5.2 (Windows) gives the answer as 0. Here's a
Integrate[Piecewise[{{DiracDelta[x-1/2], -1 < x < 1}}, 0],
{x, -Infinity, Infinity}]
For this integral, Mathematica doesn't return 0. It returns the
Integrate[Piecewise[{{2*DiracDelta[-1 + 2*x], -1 < x < 1}},
0], {x, -Infinity, Infinity}]
Can anyone help me understand what's happening here?
Cheers,
Andrew
Loading...