Question: The algorithm shown below estimates the value of a b f ( x ) d x using the composite trapezoid rule with n equally or

The algorithm shown below estimates the value of
abf(x)dx
using the composite trapezoid rule with n equally or unequally spaced base points (xi,yi)
BEGIN
INPUT xi,yi,n
sum =0
DOFOR i=1,n-1
??=??+(xi+1-xi)yi+1+yi2
ENDDO
OUTPUT sum
END
a) Represent the algorithm as a flow chart.
b) Write a Matlab function program TrapRule (x,y,n) which implements this algorithm and
returns the estimated value of the integral to the calling program.
c) Write a Matlab program which calls the function program developed in part (b) to evaluate the
integral
02xcos(x)dx
using 4 equally spaced base points and prints the result.
 The algorithm shown below estimates the value of abf(x)dx using the

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