Question: Python Code Please! Problem 3. (50%) Consider the approximate integration of a function f(x) over the interval [0, 1]. Let M be a positive integer,

Python Code Please!Python Code Please! Problem 3. (50%) Consider the approximate integration of afunction f(x) over the interval [0, 1]. Let M be a positive

Problem 3. (50%) Consider the approximate integration of a function f(x) over the interval [0, 1]. Let M be a positive integer, and let h = 1/M, and xk = kh, for k = 0, 1, 2, 3, ..., M. Thus Xo = 0 and XM = 1. Then x)dx a h|f(x0) + f(x1) + f (x2) + ... + f(x M-2) + f (x M-1). Another approximate integration formula is [ f(x)dx ~ [f(xo)+48 (71)+2f (x2)+4f(13)+...+2+(3 m2)+45 (3 m1)+f(mm)]. M - 2 JO This method, which requires M to be even, is known as Simpson's Rule. OW Implement these two methods in programs, and use each of these to approximately integrate the function f(x) = sin(1x) over the interval [0, 1], using successively the following values of M: M = 2, 4, 8, 16, ... For each of these values of M print the error, i.e., the absolute value of the difference between the approximation and the known exact value of the integral. Make sure to represent a to sufficient precision in your program! Furthermore, for each of the two methods, determine the smallest value of M for which the error is less than 10-7. How many function evaluations are required in each of these two cases? Can you describe the observed behavior of the error? In particular, for each of the two methods, can you say approximately how the error depends on h ? More specifically, it is known that the errors will be approximately proportional to hp, where p is an integer that depends on the method. Can you tell from the numerical results what p is for each of the two methods? Also can you explain what happens to the error when M gets very large

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!