Please, I need this programme in Language C. COMPUTER PROJECT # 2: AREA UNDER TH
ID: 665135 • Letter: P
Question
Please, I need this programme in Language C.
COMPUTER PROJECT # 2: AREA UNDER THE CURVE Due on Friday, July 17th 2015 Write a C program to compute numerically the area under the curve of the function f(x) = 3x3 + 2x2 + x + 3 for the range x=[1,3] usign the method of dividing the area in small trapezoidals For the students that already took Integral Calculus this can also be expressed as Eq #1: x=b=3 I = Area under the Curve (AC) 3x3 + 2x2 + x + 3 dx x=a=1 To calculate the area under the curve make use of the Trapezoidal rule which consists on splitting the area in n small trapezoidal (called sectors or panels) can be expressed as Eq #2 where ~ 11" is the counter and index of computation, from 0, 1, 2,..,n f is the integrand (or the function whose area under the curve we are searching for, equal to 3x3 + 22 x 3 ~ fo is the function f evaluated at Xo (ie, fo=f(%)= 3x1 + 2x + x0 + 3 ) ~ h is the step size (another common notation is x ) or the width of the sectors (or panels, or trapezoidal) and can be calculated as (b- a) Eq #3:Explanation / Answer
working c code for the function
#define N 1000
#include<stdio.h>
int main()
{
float i, a, b, sum = 0;
int y,x;
printf(" This program will integrate a function between two boundary limits.");
printf(" Enter the first boundary limit:");
scanf("%f", &a);
printf(" Enter the second boundary limit:");
scanf("%f", &b);
x=a;
if(a > b) { i = a; a = b; b = i; }
for(i = a; i < b; i += (b - a) / N)
{
/* Define your function below, and include the suitable header files */
y = (3 * x * x * x) + (2 * x * x) + x + 3;
sum += y * (b - a) / N;
}
printf(" Value of integration is:%.3f", sum);
return 0;
}