You are on page 1of 2

#include

#include
#include
#include
#include
#include
#include
#include
#include

<cstdlib>
<iostream>
<iostream>
<fstream>
<iomanip>
<stdio.h>
<stdlib.h>
<conio.h>
<math.h>

using namespace std;


int main()
{
int i = 1;
//Polinomio de LAgrange para chi cuadrado
//Integral por metodo de Simpson
float f=0;
float x = 0;
float h = 0;
float x1 = 0;
float x2 = 0;
float x3 = 0;
float n = 1500;
float x5 = 1;
float j = 1;
float E = 0.75;
float Er = 5;
float a = -10;
float b = 0;
i = 1;
f = (1 / (sqrt(2*3.1416)))*pow(2.718281828459,((pow(x,2))/-2));
cout << f << endl;
//Metodo de Simpson
for (j = -5; Er > 0.00001; j=j+0.005)
{
b = j;
h = (b - a) / n;
x1 = (1 / (sqrt(2*3.1416)))*pow(2.718281828459,((pow(a,2
))/-2));
x2 = (1 / (sqrt(2*3.1416)))*pow(2.718281828459,((pow(b,2
))/-2));
x3 = x1 + x2;
for (i = 1; i <= n - 1; i++)
{

x = a + i*h;
if ((i % 2) > 0)
{
x1 = x1 + (1 / (sqrt(2*3.1416)))*pow(2.7
18281828459,((pow(x,2))/-2));
}
else
{
x2 = x2 + (1 / (sqrt(2*3.1416)))*pow(2.7
18281828459,((pow(x,2))/-2));
}
}
x5 = (h*(x3 + 2 * x2 + 4 * x1)) / (3);
Er = E - x5;
}
cout << Er << endl;
cout << x5 << endl;
cout << b << endl;
system("PAUSE");
return 0;
}

You might also like