Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 Helpimage text in transcribedI 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

ISBN: 0619064625, 978-0619064624

More Books

Students also viewed these Databases questions

Question

6. What is process reengineering? Why is it relevant to training?

Answered: 1 week ago