The sinc function

The sinc function is the function $$ f(x) = \frac{\sin x}{x}. $$ To plot it over $-20 \le x \le 20$:

>>> import pylab
>>> x = pylab.linspace(-20, 20, 1001)
>>> y = pylab.sin(x)/x

__main__:1: RuntimeWarning: invalid value encountered in true_divide
>>> pylab.plot(x, y)
>>> pylab.show()

Note that even though Python warns of the division by zero at $x=0$, the function is plotted correctly: the singular point is set to the special value nan (standing for "not a number'') and is omitted from the plot.

>>> y[498:503]
array([ 0.99893367,  0.99973335,         nan,  0.99973335,  0.99893367])

The sinc function