Question: JAVA Problem 3. (50%) Consider the approximate integration of a function f(c) over 1 the interval [0,1]. Let M be a positive integer, and let

 JAVA Problem 3. (50%) Consider the approximate integration of a function

JAVA

Problem 3. (50%) Consider the approximate integration of a function f(c) over 1 the interval [0,1]. Let M be a positive integer, and let h = 1/M, and Ik = kh, for k = 0,1, 2, 3, ..., M. Thus Xo = 0 and XM = 1. Then one approximate integration formula is h h h h h f(0)dx -1+ I n[s(20+%) + f(x1+%)+F(x2+%)+ This method is known as the Midpoint Rule. Another approximate integration formula is f(x)dx = [r(x0) +4F (23)+2f (x2)+4f(83) +---+2f () +4f(2)=1)+f(2x)] = SI(M). This method, which requires M to be even, is known as the Simpson's Rule. Implement these two methods in programs, and use each of these to approximately integrate the function f2) = sin(TL) 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, which you can obtain analytically. Plot the results on the graphs. Make sure to represent a to sufficient precision in your program! Furthermore, for each of the two methods, determine from your computations the smallest value of M for which the error is less than 10-7. How many function evalu- ations are required in each of these two cases? Problem 3. (50%) Consider the approximate integration of a function f(c) over 1 the interval [0,1]. Let M be a positive integer, and let h = 1/M, and Ik = kh, for k = 0,1, 2, 3, ..., M. Thus Xo = 0 and XM = 1. Then one approximate integration formula is h h h h h f(0)dx -1+ I n[s(20+%) + f(x1+%)+F(x2+%)+ This method is known as the Midpoint Rule. Another approximate integration formula is f(x)dx = [r(x0) +4F (23)+2f (x2)+4f(83) +---+2f () +4f(2)=1)+f(2x)] = SI(M). This method, which requires M to be even, is known as the Simpson's Rule. Implement these two methods in programs, and use each of these to approximately integrate the function f2) = sin(TL) 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, which you can obtain analytically. Plot the results on the graphs. Make sure to represent a to sufficient precision in your program! Furthermore, for each of the two methods, determine from your computations the smallest value of M for which the error is less than 10-7. How many function evalu- ations are required in each of these two cases

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!