Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
26 views
a = var("a") # The lower bound b = var("b") # The upper bound c = var("c") # This is the width of each rectangle f(x) = 2*x**2 + 3*x + 1 # The function we are finding the area under, between the bounds a and b. def Riemann(f, a, b, c): """ A function to find the area under another function between the paramiters a and b. """ d = 0 while b > a: d += (f(b) * (1/c)) # summing the areas of the rectangle (with f(b) denoting the hight and 1/c the width) b -= (1/c) return d plot_data = [Riemann(f, 1, 5, c) for c in srange(1,10,1)] # Giving intiger values of c between one and ten, (so the width of the rectangles decreas). p = list_plot(plot_data) p.show()