C/C++ code#include
#include
#include
#define SMALL (-100)
#define LARGE (100)
#define DETA 0.00001
#define PREC 0.00001
#define E 2.718281828459
#define PI 3.1415926
double func(double x, double u, double o)
{
double temp1 = (x-u) / o;
double temp2 = -1 * temp1 * temp1 / 2;
double temp3 = pow(E, temp2) / o;
double temp4 = 1/ pow(2*PI, 0.5) * temp3;
return temp4;
}
void main()
{
double P = 0.5;
double u = 1;
double o = 1;
double const dLowLimit = SMALL;
double const dHighLimit = LARGE;
double const dDeta = DETA;
double dSum = 0;
double di = -100000000;
for(double i=dLowLimit; i+dDeta <= dHighLimit; i+=dDeta){
dSum += func(i, u, o) * dDeta;
if(fabs(dSum - P) <= PREC){
di = i;
break;
}
}
printf("%lf\n", di);
system("pause");
}