Question: Write a Matlab function using the following pseudo-code In this exercise, you will create a function to compute definite integrals using Simpson's rule and the
Write a Matlab function using the following pseudo-code

In this exercise, you will create a function to compute definite integrals using Simpson's rule and the com posite Simpson's rule. For an interval of integration [a, b], Simpson's rule approximates the definite integral of f(x) by (13) Divide [a, b] into n equal subintervals of length h to obtain the composite Simpson's rule n/2-1 72 (14) where xj = a +jh and h = (b-a). Note that n need to be even 1. Write a function called Simpson to evaluate the definite integral of a given function f(x) on an interval a, b. You must follow the pseudo-code: function %SIMPSON [1,h] -Simpson(f,a,b,tol) Compute definite integral of function using composite Simpson rule % 1 - Simpson (f,a,b,tol) takes as inputs anonymous function f, the limits % of the interval of integration [a,b] and tolerance tol. Output is the % definite integral 1 and subinterval length h Initialization: Set n 2 and use Eq. (13) to compute a first approximation lold Repeat: Double n and compute I with Eq. (14) Set IoldI old
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
