Question: I have the code for simpsons rule but i dont think its right PLEASE help revise it /* Integration using simpsons Rule */ #include #include

I have the code for simpsons rule but i dont think itsI have the code for simpsons rule but i dont think its right PLEASE help revise it

/* Integration using simpsons Rule */

#include

#include

#define PI 3.14159265

double f(double x);

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

int main(){

double a = 10, b = 20;

int n = 10;

printf("For n = %d, the integral is %f ", n, simpsons(n,a,b));

return 0;}

double f(double x){

double y;

y = 2*x+3;

return y;}

double simpsons(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 * (1 + i%2) * f(x);}

sum *= dx/3;

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!