#!/usr/bin/python3 # Integration with the trapezium rule def int_trapez(f, a, b, N): h = (b - a) / N # step width result = f(a)/2 + f(b)/2 # contributions of the boundary points for k in range(1, N): # add to this the contributions of the interior points xk = a + k*h result += f(xk) result *= h return result