Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WRITE A CODE IN PYTHON. Problem 3. Consider the approximate integration of a function f(x) cver the interval [0,1]. Let M be a positive integer,

WRITE A CODE IN PYTHON.

image text in transcribed

Problem 3. Consider the approximate integration of a function f(x) cver 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 x0=0 and xMr=1. Then one approximate integration formulat is 01f(x)dxh[f(x0+2h)+f(x1+2h)+f(x2+2h)++f(xM2+2h)+f(xM1+2h)]=MP(M) This method is known as the Midpoint Rule. Another approximate integration formula is 01f(x)dx3h[f(x0)+4f(x1)+2f(x2)+4f(x3)++2f(xM2)+4f(xM1)+f(xM)]=SI(M)). This method, which requires M to be even, is known as the Simpson's Rule (a) (30\%) Implement thes two methods in programs, and use euch of these to approximately integrate the function f(x)=sin(x) over the interval [0,1], using successively the following values of M:M=2,4,8,16,. For each of there values of M print the error, i.e, the ahsolute 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 x to sufficient precision in your program! Furthermore, for esch of the two methods, determine from your computations the smallest value of M for which the error is less than 10. 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 bow the error depends on h ? More sperifically, it is known that the errors will be approximatedy proportional to hP, where p is an integer that depends on the method. Can you tell from the mumerical results what p is for each of the two methods? Also can you explain what happens to the error when M gets "very large"? In the last part of this problem you will justify some of the previous results theoretically. Specifically

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Manga Guide To Databases

Authors: Mana Takahashi, Shoko Azuma, Co Ltd Trend

1st Edition

1593271905, 978-1593271909

More Books

Students also viewed these Databases questions

Question

Did you add the logo at correct size and proportion?

Answered: 1 week ago