Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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, 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

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

Matlab An Introduction with Applications

Authors: Amos Gilat

5th edition

1118629868, 978-1118801802, 1118801806, 978-1118629864

More Books

Students also viewed these Programming questions