Question: The goal is to implement and compare the basic Quadrature Rules for I = a b F(x) dx , the integral of a given function
The goal is to implement and compare the basic Quadrature Rules for I = ab F(x) dx , the integral of a given function F(x) over an interval [a,b], using M subintervals.
The integrand F(x) should be coded as a Matlab function FCN in a separate file FCN.m 1. Implement the Rectangle Rule as a Matlab function in a code RectRule.m , with both Left and with Right Heights. a. Inputs to the function RectRule should be a, b, M b. The code should print out: M and value of RL = Rectangle Rule approximation using Left heights and value of RR = Rectangle Rule approximation using Right heights nicely formated, like: RectRule for M= VALUE : RL= VALUE , RR= VALUE c. Debug on 01 3 dx with M=4. d. Debug on 01 (2x1) dx with M=4. e. Test it on 01 3(1x2)dx with M=1000. Looks like rather large M is needed to get a decent approximation... 2. Implement the Midpoint Rule as a Matlab function in a code MidptRule.m Repeat a - e above to debug and test the Midpoint Rule. 3. Implement the Trapezoidal Rule as a Matlab function in a code TrapzRule.m Repeat a - e above to debug and test the Trapezoidal Rule. 4. Create a Matlab function Quadr.m with input arguments a, b, M , which A. calls each of your quadrature rules (with the same a, b, M), B. computes the error of each rule by comparing with I_exact (see below) C. prints a (nicely formatted) table like: Comparison of Quadrature Rules using M= VALUE subintervals: Rule Value Error
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
