Created
November 18, 2016 17:34
-
-
Save jxnl/f3de3635d522612958584c5db42cdd4d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def simpson(a, b, f, N): | |
| return (1.0 / 3.0) * (2 * (((b - a) / N) * sum(f(v) for v in [i * ((b - a) \ | |
| / (2. * N)) for i in range(2 * N + 1)][1:2 * N + 1:2])) + (((b - a) / N) * \ | |
| ((f(a) + f(b)) / 2.0 + sum (f(v * ((b - a) / N) + a) for v in xrange(1, N))) | |
| )) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment