Discussion:
plot dirac delta function?
(too old to reply)
Nic
2006-07-19 10:30:04 UTC
Permalink
Hi all!

I am new to IDL and learning how to do non analytic plots such as a
dirac delta function or a finite square well. Does anybody have ideas
of what tools I should use or keywords to get started in plotting
these?

thank you
Paolo Grigis
2006-07-19 11:52:34 UTC
Permalink
here's your discrete delta function:

x=fltarr(100)
x[50]=0.01
plot,x,psym=10

if you want a step function, do instead
x[50:99]=1


Ciao,
Paolo
Post by Nic
Hi all!
I am new to IDL and learning how to do non analytic plots such as a
dirac delta function or a finite square well. Does anybody have ideas
of what tools I should use or keywords to get started in plotting
these?
thank you
k***@wizard.net
2006-07-19 15:31:02 UTC
Permalink
Post by Nic
Hi all!
I am new to IDL and learning how to do non analytic plots such as a
dirac delta function or a finite square well. Does anybody have ideas
of what tools I should use or keywords to get started in plotting
these?
thank you
The Dirac delta function is defined by the following equations:

delta(x) = 0 if x ne 0

integral of delta(x) dx from x0 to x1 = 1, if x0 < 0 and x1 > 0

Notice that this definition fails to identify explicitly the value of
delta(0). That's because there's no meaningful value that can be
assigned to delta(0). The best you can do is to call it infinity, but
even that's not quite right, for reasons that I don't remember right
now.
Conceptually, you can consider delta(x) to be a member of a family of
functions delta(x,e), with the following properties:

delta_e(x,e) =0 for x<=-e or x>=e
delta_e(0,e) = 1/e
delta_e(x,e) is linear for -e<=x<=0, and for 0<=x<=e

With this definition, you can think of delta(x) as the limit, as e->0,
of delta_e(x,e); except that this limit is not well-defined.

What you need to do to make an expression containing a delta function
meaningfull is to integrate it. For instance:

integral f(x)*delta(a*(x-x1)) dx from x0 to x2 =
f(x1)/a if x0<x1<x2
0 if x1<x0<x2 or x0<x2<x1

Therfore, it's rather meaningless to try to plot the Dirac delta
function itself. If, however, you insist on doing so, you need to scale
the y axis so that it maps an infinite range of values into a finite
range on your screen. One simple transformation with this property is
y=logit(norm), where norm is a value that runs from 0 to 1, and
logit(norm) = alog(norm/(1-norm)). You can implement this in IDL by
defining a function to be used as a YTICKFORMAT option of a PLOT
command:

FUNCTION logit_format, axis, index, value
IF(value LE 0) THEN RETURN, '-INFINITY';
IF(value GE 1.0) THEN RETURN, '+INFINITY'
RETURN, STRING(alog(value/(1-value)), FORMAT='(G9.3)')
END

The Dirac delta function is almost never used without shifting it's
center. Let x0 be the shifted center, and let xmin and xmax be the
domain over which you wish to plot delta(x-x0). Then the following
commands will plot it "sort of" correctly:

PLOT, [xmin, x0, x0, x0, xmax], [0.5, 0.5, 1.0, 0.5, 0.5],
YTICKFORMAT='logit_format'

If you want to plot another function f(x) with the same scaling, you
must rescale the y values, as follows:

OPLOT, x, exp(f(x))/(1+exp(f(x)))

The Heaviside step function is much simpler. It's defined as:

H(x) = 0 for x<0
H(0) = 0.5
H(x) = 1.0 for x>0

It's almost never used without scaling and offsets, so I'll show how to
plot y1*H(x-x0)+y0:

PLOT, [xmin, x0, x0, x0, xmax], [y0, y0, 0.5*(y0+y1), y1, y1]
Benjamin Hornberger
2006-07-19 16:28:56 UTC
Permalink
Post by k***@wizard.net
delta(x) = 0 if x ne 0
integral of delta(x) dx from x0 to x1 = 1, if x0 < 0 and x1 > 0
Notice that this definition fails to identify explicitly the value of
delta(0). That's because there's no meaningful value that can be
assigned to delta(0). The best you can do is to call it infinity, but
even that's not quite right, for reasons that I don't remember right
now.
I think that (the last paragraph) applies to the continuous case. In the
discrete case, it follows quite clearly from the two equations above
that the delta function must be an array which is 1 for the center (more
on that below) and zero otherwise. Two examples:

1. Convolution of a function (array) with a delta function must
reproduce the function (or shift if the delta function is not centered).
This is clearly fulfilled by an array which has a 1 in one element and
zeroes otherwise.

2. The Fourier Transform of a (centered) delta function is a constant.
The value of the constant depends somewhat on the definition of the FT
(in IDL, the forward FFT of a delta function as defined above is a
constant 1/N, N being the number of array elements, and the reverse FFT
is a constant 1).

You have to keep in mind that for frequency analysis, IDL assumes the
zero frequency ("center") to be at the zero element in real AND Fourier
space. I, like many others, prefer to shift all arrays by minus/plus N/2
before and after an FT and work on "centered" arrays, which makes the
plots look more intuitive.
k***@wizard.net
2006-07-19 19:20:16 UTC
Permalink
Post by Benjamin Hornberger
Post by k***@wizard.net
delta(x) = 0 if x ne 0
integral of delta(x) dx from x0 to x1 = 1, if x0 < 0 and x1 > 0
Notice that this definition fails to identify explicitly the value of
delta(0). That's because there's no meaningful value that can be
assigned to delta(0). The best you can do is to call it infinity, but
even that's not quite right, for reasons that I don't remember right
now.
I think that (the last paragraph) applies to the continuous case. In the
discrete case, it follows quite clearly from the two equations above
that the delta function must be an array which is 1 for the center (more
In my experience, the term "Dirac delta function" is restricted to what
you call the continuous case. The corresponding thing for the discrete
case is referred to as the Kroenecker delta. See, for example,
<http://www.physics.umd.edu/courses/Phys374/fall04/hw/MP27.htm>.

I think it's even less meaningful (though much easier!) to plot the
kroenecker delta than the Dirac delta function. It's only defined on a
discrete set of points, so drawing lines between the consecutive points
of the plot would be inappropriate.
s***@gmail.com
2006-07-24 00:54:39 UTC
Permalink
FYI, while the definition can be approached a number of equivalent
ways, the value of the Dirac IS "well-defined" at delta(x).
Technically, it's "well-defined" at the value such that its argument is
zero (which here is x=0).

The value is indeed infinity. At least, that's how it's used in
physics.
k***@wizard.net
2006-07-24 02:07:52 UTC
Permalink
Post by s***@gmail.com
FYI, while the definition can be approached a number of equivalent
ways, the value of the Dirac IS "well-defined" at delta(x).
Technically, it's "well-defined" at the value such that its argument is
zero (which here is x=0).
The value is indeed infinity. At least, that's how it's used in
physics.
No, it is not. I'm very well versed in the use of the dirac delta
function in physics, and the value of delta(0) is never used in any
meaningful sense. Any equation which attempts to make use of the value
at zero is meaningless. The dirac delta function only becomes
meaningful after you've integrated over it.
s***@gmail.com
2006-07-30 05:17:40 UTC
Permalink
Ah, I see we're about to head off into the realm of defining functions,
ever a popular discussion (not the least of which is because I relish
the opportunity to learn more about it, not being a mathematician). Why
do you say this? In plasma kinetic theory a while back, the prof give
us the pop quiz about the value of particle distributions made from
sums of delta functions. As with the "How do you put an elephant into
the refrigerator?" test, everyone jumped to the wrong answer since the
integral of the Dirac delta is 1. The function wasn't a sum of
integrals, its a sum of deltas, so the value of the distribution at a
particle's parameters in the phase space we were working in is
infinity.

Looking at a Dirac delta as the limit of a sequence of Guassians as the
width of the guassian goes to zero with the constraint that the
integral of the Dirac goes to one also provides the value of infinity,
because that's the only way an integral could possibly be non-zero when
its upper and lower bounds are the same.
k***@wizard.net
2006-07-30 14:18:20 UTC
Permalink
Post by s***@gmail.com
Ah, I see we're about to head off into the realm of defining functions,
ever a popular discussion (not the least of which is because I relish
the opportunity to learn more about it, not being a mathematician). Why
do you say this? In plasma kinetic theory a while back, the prof give
us the pop quiz about the value of particle distributions made from
sums of delta functions. As with the "How do you put an elephant into
the refrigerator?" test, everyone jumped to the wrong answer since the
integral of the Dirac delta is 1. The function wasn't a sum of
integrals, its a sum of deltas, so the value of the distribution at a
particle's parameters in the phase space we were working in is
infinity.
That's just a test question about a intrinsically meaningless
intermediate step in a calculation. The only thing you can ever
meaningfully do with such a particle distribution function is integrate
over it, one way or another. The value of such a function at a given
point is meaningless, except in those places where it's zero, in which
case it's meaningful only as a simplified approximation to reality.
It's value at any point where it's non-zero is not a measurable
quantity. Can you show me any actual calculations where the value of a
dirac delta function at 0 is actually used to calculate something
meaningful, without being integrated over?
s***@gmail.com
2006-07-30 05:27:28 UTC
Permalink
Post by k***@wizard.net
Post by s***@gmail.com
FYI, while the definition can be approached a number of equivalent
ways, the value of the Dirac IS "well-defined" at delta(x).
Technically, it's "well-defined" at the value such that its argument is
zero (which here is x=0).
The value is indeed infinity. At least, that's how it's used in
physics.
No, it is not. I'm very well versed in the use of the dirac delta
function in physics, and the value of delta(0) is never used in any
meaningful sense. Any equation which attempts to make use of the value
at zero is meaningless. The dirac delta function only becomes
meaningful after you've integrated over it.
FYI: the physical meaning of delta is used ALL the damn time when
you're talking about the spatial distribution of point particles (think
electrons and other extensionless subatomic particles here). If the
particle has no extension, as is generally believed to be true for,
e.g. electrons due to quantum considerations (classical radius of the
electron and arguments like that), then the only way to describe a mass
distribution is by summing up a bunch of things that are zero except
for at a single point in "configuration space" with no physical
extension. Following the logic, in any phase space, when the object's
parameters are point values in that space, you get the same behavior
for those parameters: a Dirac for the object's state. To say that
delta(x-a) just means that the particle is at x=a in that phase space;
x=0 refers to the origin of the phase space. These things are used all
the time or underly other calculations that are used all the time. If
you are using statistical mechanics at all, you should be seeing this
regularly.

Another physical application is as the Green's function corresponding
to Guass's law for a point charge, the mathematics of which gets
quickly generalized for minimum variance packet in quantum mech. The
fun just never stops.
k***@wizard.net
2006-07-30 14:32:36 UTC
Permalink
...
Post by s***@gmail.com
Post by k***@wizard.net
No, it is not. I'm very well versed in the use of the dirac delta
function in physics, and the value of delta(0) is never used in any
meaningful sense. Any equation which attempts to make use of the value
at zero is meaningless. The dirac delta function only becomes
meaningful after you've integrated over it.
FYI: the physical meaning of delta is used ALL the damn time when
I was not referring to the physical meaning of delta, which is that it
represents a point source. I was referring specifically to the actual
value of the Dirac delta function at 0; any equation that involves
evaluating that function at that point, rather than integrating over
it, to calculate a physically meaningful quantity is an error.
Post by s***@gmail.com
you're talking about the spatial distribution of point particles (think
electrons and other extensionless subatomic particles here). If the
particle has no extension, as is generally believed to be true for,
Yes, it's considered quite likely that quarks and leptons are true
point particles, which means that their physical extent is accurately
described by a dirac delta function. However, any physically meaningful
quantity you can calculate is not directly related to the value of that
function at its center, but is instead calcuated directly or
indirectlly from an integral over that function.
Post by s***@gmail.com
e.g. electrons due to quantum considerations (classical radius of the
electron and arguments like that), then the only way to describe a mass
distribution is by summing up a bunch of things that are zero except
for at a single point in "configuration space" with no physical
extension. Following the logic, in any phase space, when the object's
parameters are point values in that space, you get the same behavior
for those parameters: a Dirac for the object's state. To say that
delta(x-a) just means that the particle is at x=a in that phase space;
x=0 refers to the origin of the phase space. These things are used all
the time or underly other calculations that are used all the time. If
you are using statistical mechanics at all, you should be seeing this
regularly.
I haven't done any statistical mechanics in more than a decde, but when
I was studying it, we used dirac delta functions all over the place.
It's a very useful concept, and I've never denied that fact. But we
never used the value of that fucntion at zero for any meaningful
purpose. It only became meaningful after integration.
Post by s***@gmail.com
Another physical application is as the Green's function corresponding
to Guass's law for a point charge, the mathematics of which gets
quickly generalized for minimum variance packet in quantum mech. The
fun just never stops.
Again, that's an example where a Dirac delta function is a very useful
tool - but only inside an integral, which is how Green's functions are
always used. It's meaningless without the integral.
Carsten Lechte
2006-08-11 21:18:25 UTC
Permalink
I agree with what you said. The Dirac "function" is is
only defined by what it does under an integration. It is
really a distribution (generalised function), since no
normal function exists that behaves like the Dirac delta.

See http://en.wikipedia.org/wiki/Distribution_%28mathematics%29
for some details on distributions.


chl
k***@wizard.net
2006-08-11 22:35:05 UTC
Permalink
Post by Carsten Lechte
I agree with what you said. The Dirac "function" is is
only defined by what it does under an integration. It is
really a distribution (generalised function), since no
normal function exists that behaves like the Dirac delta.
See http://en.wikipedia.org/wiki/Distribution_%28mathematics%29
for some details on distributions.
Thanks. I knew that mathematicians had tamed the DIrac Delta into
something they could actually make sense of, but I couldn't remember
the name they gave to the concept; it's probably been more than a
decade since I last needed to use that name.
p***@tcd.ie
2016-11-25 10:13:21 UTC
Permalink
;dirac delata function
x = fltarr(100) ; creating 1D array of 100 zeroes
x(50.0) = 1.0 ; setting one point from array to not equal zero

plot, x ; plotting function

Loading...