Question: Consider the blocks of code below. Match each labelled line of code with the statement that best describes its purpose. import numpy as np import

Consider the blocks of code below. Match each labelled line of code with the statement that best describes its purpose. import numpy as np import numpy.random as nrand def integrationA (f,a,b,n) : dx=(ba) \#\# (a) x=np. linspace (a,b,n+1) \#\# (b) y=f(x) \#\# (c) return npsum(y[0:n])dx##(d) def integration B(f,a,b,n) : dx=(ba) x=np. linspace (a,b,n+1) y=f(x) return npsum(y[1:n+1])dx \#\# (e) def integrationC (f,a,b,n) : dx=(ba) x=a+(ba)n rand. random (n) \#\# (f) y=f(x) \#\# (g) return npsum(y)dx##(h) (1) Creates an array of randomly chosen values between a and b, inclusive. (2) Computes the Monte Carlo approximation of the definite integral of f on [a,b]. (3) Creates an array of n+1 equally spaced values between a and b, inclusive. (4) Computes the left Riemann sum approximation of the definite integral of f on [a,b]. (5) Creates an array of n+1y-values, where y=f(x). (6) Defines the width of each approximating rectangle. (7) Computes the right Riemann sum approximation of the definite integral of f on [a,b]. (8) Creates an array of ny-values, where y=f(x). So, for example, if you think that (a) matches (3), (b) matches (5), (c) matches (1), (d) matches (2), (e) matches (7), (f) matches (4), (g) matches (5), and (h) matches (6), then you would enter 3,5,1,2,7,4,5,6 into the answer box below
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
