Skip to content

Instantly share code, notes, and snippets.

@emwdx
Created August 31, 2012 11:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emwdx/3551632 to your computer and use it in GitHub Desktop.
Save emwdx/3551632 to your computer and use it in GitHub Desktop.
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