comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: plot dirac delta function?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: plot dirac delta function? [message #49360 is a reply to message #49359] Wed, 19 July 2006 08:31 Go to previous messageGo to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
Nic wrote:
> 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]
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Irregular grid -> 2D binned
Next Topic: Re: LINUX IDL Install Help

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 21:55:22 PDT 2025

Total time taken to generate the page: 1.19929 seconds