pylab, integral of sinc function

Schüle Daniel uval at rz.uni-karlsruhe.de
Mon Feb 19 11:24:11 EST 2007


Hello,

In [19]: def simple_integral(func,a,b,dx = 0.001):
    ....:     return sum(map(lambda x:dx*x, func(arange(a,b,dx))))
    ....:

In [20]: simple_integral(sin, 0, 2*pi)
Out[20]: -7.5484213527594133e-08

ok, can be thought as zero

In [21]: simple_integral(sinc, -1000, 1000)
Out[21]: 0.99979735786416357

hmm, it should be something around pi
it is a way too far from it, even with a=-10000,b=10000

In [22]: def ppp(x):
    ....:     return sin(x)/x
    ....:

In [23]: simple_integral(ppp, -1000, 1000)
Out[23]: 3.1404662440661117

nice

is my sinc function in pylab broken?
is there a better way to do numerical integration in pylab?

Regards, Daniel



More information about the Python-list mailing list