Question: Please explain using matlab The aim of this lab is to test the accuracy of the adaptive Simpson's rule for computing definite integrals numerically. 2



Please explain using matlab
The aim of this lab is to test the accuracy of the adaptive Simpson's rule for computing definite integrals numerically. 2 Consider the integral cos(2x)e -* dx. (1). Calculate the exact value of the integral. (2). Use the composite Simpson's rule over the whole interval to evaluate the integral using Xi = ih, where i = 0, ..., n and h = 211. Use n=10, 20, 50,100 . Produce one plot showing the error from the numerical quadrature as a function of n. What is the error? Compare the result to the error estimate. (3). Develop algorithms to perform adaptive numerical quadrature for a general definite integral f(x)dx using the Simpson's rule. a (4). Apply the algorithm to the integral listed above, with desired accuracy 0.5x 10-4. Suppose the maximum number of levels is N - 20. Is this possible? If not, what do you need to set the maximum number of levels to? How many quadrature points would the non-adaptive method require for this level of accuracy? ADAPTIVE SIMPSON'S RULE: INPUT endpoints a, b, the tolerance and N (the limit to the number of levels) OUTPUT S, the approximation to the integral Step 1. Set S=0 i-1 & - 10 a = a h - (b-a)/2 FA - f(a) FC -f(a+h) FB, -f(b) S-h(FA, +4FC, +FB)/3 L-1 Step 2. While i> 0 do STEPS 3-5 Step 3. Set FD-f(a+h/2) FE - f(a, +3h/2) SI - h (FA, +4FE+FB)/6 S2 - h (FC, +4FE+FB)/6 vl- a v2 - FA v3 - FC v4 - FB v5- v6 - v7-S V8 - 2 Step 4. Seti-i-1 %delete this level Step 5. If I S1 + S2 - v7k v6 Then S - $1+S2 Else If v8 2N Then OUTPUT('LEVEL EXCEEDED') %procedure fails STOP Else %add one level Set i =i+1 %data for right half subinterval a-vl+v5 FA - v3 FC, - FE FB - v4 h - v5/2 & -V6/2 S - S2 L -v8+1 Set i=i+1 %data for left half subinterval a, - v1 FA - v2 FC) - FD FB, - v3 h, - - E - 8-1 S-S1 L-L-1 Step 6, OUTPUT (S) STOP
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
