/* This is a program to find out the inter-
molecular distance of NaCl.
This program is created by Md. Enamul Hoque.*/
# include
# include
# include
using namespace std;
double funct (double x);
double f (double x);
int initial ();
int main (){
double x, dl = 1E-6;
int tag = 0;
x = initial ();
do {
if (x + dl < funct (x))
tag = 1;
x += dl;
}while (tag != 1);
cout << "The inter-molecular distance of NaCl is: " << x << " A." << endl;
cout << "The error in this value is in the order of: " << dl << endl;
getch ();
return 0;
}
double funct (double x){
double dl = 1E-6;
return (x + dl * f(x) / (f(x) - f(x - dl)));
}
int initial (){
int a = 0, x = 0, tag = 0;
do {
if (f(x) < 0){
a = x;
x++;
}
else
tag = 1;
}while (tag != 1);
return (x);
}
double f (double x){
double alpha = 1090, ro = 0.33, e2 = 14.4;
return ((-e2 / (x * x)) + (alpha / ro) * exp (-x / ro));
}