def rectangles(f,a,b): dx = 1e-7 x = a S = 0 while x<=b: S += f(x)*dx x += dx return S