I wrote this program which finds the definite integral of a function. Where in the program could I optimize this code:
def trapezium(f,n,a,b):
h=(b-a)/float(n)
area = (0.5)*h
sum_y = (f(0)+f(b))
i=a
while i<b:
print i
sum_y += 2*f(i)
i += h
area *= sum_y
return area
def f(x):
return x ** 2
print trapezium(f, 10000, 0, 5)