Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Calculation of definite integrals
a = 0
b = 1
N = 5000
area = 0
delta_x = (b - a)*1./N
def f(t):
return t**2
for i in range(N):
x = i*delta_x + a
area=area + f(x)*delta_x
#print "x: %0.4f f(x): %0.4f i: %0.0f"%(x,f(x),i)
print area
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment