Re: pylab, integral of sinc function

2007-02-22 Thread Fernando Perez
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]:

pylab, integral of sinc function

2007-02-19 Thread Schüle Daniel
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]:

Re: pylab, integral of sinc function

2007-02-19 Thread Schüle Daniel
my fault In [31]: simple_integral(lambda x:sinc(x/pi), -1000, 1000) Out[31]: 3.14046624406611 -- http://mail.python.org/mailman/listinfo/python-list

Re: pylab, integral of sinc function

2007-02-19 Thread Paul Rubin
Schüle Daniel [EMAIL PROTECTED] writes: In [19]: def simple_integral(func,a,b,dx = 0.001): : return sum(map(lambda x:dx*x, func(arange(a,b,dx Do you mean def simple_integral(func,a,b,dx = 0.001): return dx * sum(map(func, arange(a,b,dx))) --

Re: pylab, integral of sinc function

2007-02-19 Thread Schüle Daniel
[...] In [19]: def simple_integral(func,a,b,dx = 0.001): : return sum(map(lambda x:dx*x, func(arange(a,b,dx Do you mean def simple_integral(func,a,b,dx = 0.001): return dx * sum(map(func, arange(a,b,dx))) yes, this should be faster :) --

Re: pylab, integral of sinc function

2007-02-19 Thread Paul Rubin
Schüle Daniel [EMAIL PROTECTED] writes: return dx * sum(map(func, arange(a,b,dx))) yes, this should be faster :) You should actually use itertools.imap instead of map, to avoid creating a big intermediate list. However I was mainly concerned that the original version might be incorrect.

Re: pylab, integral of sinc function

2007-02-19 Thread Robert Kern
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]: