Numerical integration: Difference between revisions

Content added Content deleted
(+ Pascal)
Line 785: Line 785:


def integrate( f, a, b, steps, meth):
def integrate( f, a, b, steps, meth):
h= (b-a)/steps
h = (b-a)/steps
ival = h*sum( (meth(f, a+i*h, h) for i in range(0,steps)))
ival = h * sum(meth(f, a+i*h, h) for i in xrange(steps))
return ival
return ival