Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <stdio.

h>
#include <conio.h>
#include <math.h>
double fx(double x);
double integral(double a, double b, double c[], double x[]);
void main()
{
double c[4], x[4], a, b;
c[0]=c[3]=0.3478548; c[1]=c[2]=0.6521452;
x[0]=-0.861136312; x[3]=0.861136312; x[1]=-0.339981044; x[2]=0.339981044
;
printf("Input lower bound a and upper bound b : ");
scanf("%lf%lf", &a, &b);
printf("Result = %lf", integral(a,b,c,x));
getch();
}
double fx(double x)
{
return powl(x,0.1)*(1.2-x)*(1-exp(20*x-20));
}
double integral(double a, double b, double c[], double x[])
{
double sum=0;
for (int i=0; i<4; i++)
sum+=(c[i]*fx((b-a)/2*x[i]+(a+b)/2));
return sum*(b-a)/2;
}

You might also like