Schüle Daniel wrote: > 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?
A couple things: 1) The function is not from pylab, it is from numpy. 2) Look at the docstring of the function, and you will notice that the convention that sinc() uses is different than what you think it is. In [3]: numpy.sinc? Type: function Base Class: <type 'function'> Namespace: Interactive File: /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/numpy-1.0.2.dev3521-py2.5-macosx-10.3-fat.egg/numpy/lib/function_base.py Definition: numpy.sinc(x) Docstring: sinc(x) returns sin(pi*x)/(pi*x) at all points of array x. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list