Question: 13. Write a user defined MATLAB function to compute the definite integral, intout, of a function f (x) in the limits x0 to xn

13. Write a user defined MATLAB function to compute the definite integral,

 

13. Write a user defined MATLAB function to compute the definite integral, intout, of a function f (x) in the limits x0 to xn with an accuracy of sigfig significant digits using an n-segment composite trapezoidal rule as represented by the formula: 1 = f(x)dx= =[f(x)+2 "-1 f(x)+2f(x+mh) + f (x) where h= Xx,,-Xo . n m=1 3 Use Romberg extrapolation, I = (41 Fine-Coarse), where I fine and I coarse represents trapezoidal integrals evaluated with finer (n) and coarser grids respectively, for a faster convergence. Your code needs to be capable of making a decision on grid refinements based on the desired accuracy. As discussed in class, start iterating with n = 1, and keep on doubling n until you reach the desired accuracy. This will make the step size / for the coarser grid calculation two times that of the finer grid calculation. Using this strategy, it was discussed in class that in each subsequent grid refinement, you need to evaluate the function f(x+mh) only for the odd values of m. To start with, initialize IFine equal to the trapezoidal integral corresponding to n = 1. The convergence criterion is based on the relative error in IFine Use your code to solve the following integrals with an accuracy of 14 significant digits. In all cases calculate the error and note down the number of iterations required to achieve the desired accuracy. (a) / = = (t-2)dt; Analytical solution, 1 = 84 (b) 1 = 22w-w-3 dw; Analytical solution, I = -32/15 w2

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 Programming Questions!