Write the following integration routines: 1) a Left Handed Riemann Sum routine 2
ID: 3610858 • Letter: W
Question
Write the following integration routines:
1) a Left Handed Riemann Sum routine
2) a Right Handed Riemann Sum routine
3) A trapazoidal Riemann Sum routine
4) A routine which uses Simpson's rule (see:http://en.wikipedia.org/wiki/Simpson's_rule for moreinformation.)
C++ prototypes:
double lhrs(double f[], double x[], int num)
double rhrs(double f[], double x[], int num)
double trap(double f[], double x[], int num)
double simpsons(double f[], double x[], int num)
where f[] holds values of the function to be integrated and x[]the x coordinates of the points such that f[i]=f(x[i]), and botharrays are of length num.
Explanation / Answer
/* Wrote the function for left riemann sum, right riemann sum,trapzoidal rule, simpson's rule */ #include #include using namespace std; double lhrs(double f[], double x[], int num) { double LRS=0.0; for(int i=1; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.