Question: Please Help I wrote a code fot the trapezoid rule but im not sure its right. PLEASE edit the code and help me with the

Please HelpPlease HelpI wrote a code fot the trapezoid rule but im notI wrote a code fot the trapezoid rule but im not sure its right. PLEASE edit the code and help me with the simpsons rule.

/* Integration using Trapezoidal Rule */

#include

#include

#define PI 3.14159265

double f(double x);

double trapz(int n, double a, double b);

int main(){

double x0 = 10, xn = 20;

int n = 100;

printf("For n = %d, the integral is %f ", n, trapz(n, x0, xn));

return 0;}

double f(double x){

double y;y = 2*x+3;

return y;}

double trapz(int n, double a, double b){

int i;

double dx, x, sum;dx = (b -a) / n;

sum = f(a) + f(b);

for (i = 1; i

x = a + dx * i;

sum += 2 * f(x);}

sum *= dx/2;

return sum;}

Problem 8: Using Simpson's rule and trapezoidal rule, estimate J 2x +3 dx using 10, 20 and 30 intervals. 10

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!