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
2: 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 integration A(f,a,b,n) : dx=(ba) sit (a) x=np. linspace (a,b,n+1) and (b) y=f(x), "in (c) return npsun(y[9:n])dx as (d) def integrationB (f,a,b,n) : dx=(ba) x=np.1 inspace (a,b,n+1) y=f(x) return np+sin(y[11n+1])dx=n=(e) def integrationc (f,a,b,n) : dx=(ba) x=a+(ba) "nrand.randoen( n) win (f) y=f(x) oin (g) return np+sun(y)dx sin (h) (1) Creates an array of n+1y-values, where y=f(x). (2) Creates an array of n+1 equally spaced values between a and b, inclusive. (3) Creates an array of randomly chosen values between a and b, inclusive. (4) Computes the Monte Carlo approximation of the definite integral of f on [a,b]. (5) Creates an array of ny-values, where y=f(x). (6) Computes the right Riemann sum approximation of the definite integral of f on [a,b]. (7) Defines the width of each approximating rectangle. (8) Computes the left Riemann sum approximation of the definite integral of f on [a,b]. 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. 2: 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 integration A(f,a,b,n) : dx=(ba) sit (a) x=np. linspace (a,b,n+1) and (b) y=f(x), "in (c) return npsun(y[9:n])dx as (d) def integrationB (f,a,b,n) : dx=(ba) x=np.1 inspace (a,b,n+1) y=f(x) return np+sin(y[11n+1])dx=n=(e) def integrationc (f,a,b,n) : dx=(ba) x=a+(ba) "nrand.randoen( n) win (f) y=f(x) oin (g) return np+sun(y)dx sin (h) (1) Creates an array of n+1y-values, where y=f(x). (2) Creates an array of n+1 equally spaced values between a and b, inclusive. (3) Creates an array of randomly chosen values between a and b, inclusive. (4) Computes the Monte Carlo approximation of the definite integral of f on [a,b]. (5) Creates an array of ny-values, where y=f(x). (6) Computes the right Riemann sum approximation of the definite integral of f on [a,b]. (7) Defines the width of each approximating rectangle. (8) Computes the left Riemann sum approximation of the definite integral of f on [a,b]. 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
