Post by NicHi 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]