Skip to content

Instantly share code, notes, and snippets.

@airled
Created January 23, 2017 23:09
Show Gist options
  • Save airled/4efe1c9e8553de5f84c72d8cdd4e0590 to your computer and use it in GitHub Desktop.
Save airled/4efe1c9e8553de5f84c72d8cdd4e0590 to your computer and use it in GitHub Desktop.
def s(l, start, stop, accuracy = 1000000)
range = stop - start
dx = range / accuracy.to_f
sum = 0
accuracy.times do
sum += 0.5 * (l.(start) + l.(start + dx)) * dx
start += dx
stop += dx
end
sum
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment