This program shows a table of results of a probability equation by Simpson's method of numerical integration and adds it to a txt, but none of the results should be greater than 1, and I do not know what the problem is?

Within the code, n is the number of iterations that the "Calculate" function has, which returns a string to be able to put it more easily to the txt. There are 600 equations and each will have n cycles, so neither can be very large.

The integral is for normal distribution, to form its tables from -6 to 6.

`#include `
#include
#include
#include
#include
using namespace std;
string Calculate (float b) {
string answer, bstring, finalstring;
char bchar[4], finalize[12];
float a = -6;
float n = 15000;
int i;
float sum = 0.0, power, formula, constant, pot, e;
final float = (b-a) / (2 * n);
float sigx = (b-a) / n;
constant = (1 / 2.506628274631000502415765284811);
// printf ("sigx:% f n", sigx);
float x = a;
for (i = 0; i<=n; i++){
//printf("X%d=%fn", (i-1), x);
potencia=pow(x,2);
potencia/=-2;
e=pow(2.71828182,potencia);
if(i==0 || i==n){
formula=e;
}else{
formula=(e*2);
}
/*if(i==n){
printf("Potencia=%.20fn",potencia);
printf("e=%.20fn",e);
printf("formula=%.20fn",formula);
}*/
suma+=formula;
//printf("Suma=%.25fn",suma);
x+=sigx;
}
final=final*suma*constante;
//printf("B=%.2f-->Result =%. 10f n ", b, final);
sprintf (bchar, "%. 2f", b);
sprintf (end, "%. 10f", end);
bstring = bchar;
finalstring = finalchar;
// cout << "B =" << bstring << endl;
// cout << "Final =" << bstring <"+ finalstring;
// cout << answer << endl;
return response;
}
int main () {
printf ("This program shows the results of the numeric integral of: n");
printf ("(1 / ((2pi) ^ (1/2))) (e ^ ((- 1/2) (z ^ 2))) n");
printf ("Evaluated from -6 to different limits up to 6 n");
system ("pause");
float b = -5.98;
int i = 1;
string response;
ofstream write ("bes.txt");
int cont = 1;
printf (" n");
while (b <= 6.00) {
/ * if ((i% 2) == 0) {
printf ("");
}
if ((i% 2) == 0) {
printf (" n");
} printf ("% d:", i); * /
i ++;
answer + = Calculate (b);
//printf("%d.- B =% f n ", i, b);
b = b + 0.02;
if (i == 26 || i == 76 || i == 128 || i == 181 || i == 233 || i == 578 || i == 338 || i == 394 || i == 451 || i == 501 || i == 551) {
b = b + 0.000001;
}
if (i == 578) {
b = b-0.000001;
}
if (cont == 4) {
write << answer << endl;
cout << answer << endl;
answer = "";
cont = 1;
} else {
answer = answer + "";
cont ++;
}
}
write.close ();
return 0;

}