mirror of
https://github.com/janishutz/eth-summaries.git
synced 2026-01-12 01:58:24 +00:00
5 lines
183 B
Python
5 lines
183 B
Python
def simpson(f, a, b, N):
|
|
x, h = np.linspace(a, b, 2 * int(N) + 1, retstep=True)
|
|
I = h / 3.0 * (np.sum(f(x[::2])) + 4.0 * np.sum(f(x[1::2])) + f(x[0]) - f(x[-1]))
|
|
return I
|