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]:
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]:
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
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)))
--
[...]
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 :)
--
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.
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]: