0

The error is: F:\C ++ Numerical Methods\Newton_Raphson.cpp(199) : fatal error C1004: unexpected end of file found

```
#include <cmath>
#include <iostream>
using namespace std;
double F ( double X )
{
return pow ( X, 4) - 9*pow ( X, 3 ) - 2*pow (X, 2) + 120*X - 130;
}
double DF (double X)
{
return 4*pow (X, 3) - 27*pow (X, 2) - 4*X + 120;
}
double DDF (double X)
{
return 12*pow (X, 2) - 54*X -4;
}
int main()
{
char ANSWER;
int TALLY;
double X, XL, XR, XS, Y, YL, YR;
double XB, XND, STEPSIZE;
double XO, XN, FX, DFX, DDFX;
double INT_ACC, ROOT_ACC, TOO_BIG, TOO_SMALL;
ANSWER = 'Y';
TALLY = 0;
XL = 0.0;
XR = 0.0;
XS = 0.0;
X = 0.0;
Y = 0.0;
YL = 0.0;
YR = 0.0;
XB = 0.0;
XND = 0.0;
STEPSIZE = 0.0;
XO = 0.0;
XN = 0.0;
FX = 0.0;
DFX = 0.0;
DDFX = 0.0;
INT_ACC = 0.0;
ROOT_ACC = 0.0;
TOO_BIG = 0.0;
TOO_SMALL = 0.0;
while (ANSWER == 'Y');
cout<<"What is the left-most interval endpoint? ";
cin>> XB;
cout<<"What is the right-most interval endpoint? ";
cin>> XND;
cout<<"What is the desired step-size for function evaluation? ";
cin>> STEPSIZE;
cout<<"How close can the approximate root be to the true root to invoke root-finding? ";
cin>> INT_ACC;
cout<<"What is the size limit on the 2nd derivative? ";
cin>> TOO_BIG;
cout<<"How close can the 1st derivative get to zero? ";
cin>> TOO_SMALL;
cout<<"What is the desired accuracy for root-finding? ";
cin>> ROOT_ACC;
XL = XB;
while ( true ) {
YL = F ( XL );
XR = XL + STEPSIZE;
YR = F ( XR );
if ( YL * YR > 0 ) {
if ( XR >= XND ) goto end;
XL = XR;
YL = YR;
}
if ( YL * YR == 0 ) {
if ( YL == 0.0 ) {
cout<<"This is a root. "<< XL<<endl;
if ( XR >= XND ) goto end;
XL = XR;
}
else {
cout<<"This is a root. "<< XR<<endl;
if ( XR >= XND ) goto end;
XL = XR + STEPSIZE;
}
}//end if
if ( YL * YR < 0 ) {
XS = XR;
while ( true ) {
X = ( XL + XR ) / 2;
Y = F ( X );
if ( YL * Y > 0 ) {
XL = X;
YL = Y;
}
if ( YL * Y == 0 ) {
cout<<"This is a root. "<< X<<endl;
XR = X;
YR = Y;
}
if ( YL * Y < 0 ) {
XR = X;
YR = Y;
}
if ( fabs(XR - XL) < INT_ACC) {
cout<<"This interval contains a root at "<< XL <<','<< XR<<endl;
XO = (XL + XR)/2.0;
TALLY = 1;
while ( true ) {
FX = F(XO);
DFX = DF(XO);
DDFX= DDF(XO);
if (fabs(DDFX)>= TOO_BIG) {
cout<<"Condition 1 FAILS: 2nd derivative too large. ";
}
break;
}//end of while
if (fabs(DFX) <= TOO_SMALL) {
cout<<"Condition 2 FAILS: 1st derivative too close to zero. ";
}
}//end if
if (TALLY > 15) {
cout<<"Slow convergence. Possible infinite loop.";
}
}//end while
XN = XO - (FX/DFX);
if (fabs(XN-XO) < ROOT_ACC) {
cout<<"The root is: "<<XN<<endl;
}
else
XO = XN;
TALLY = TALLY + 1;
break;
}
XL = XS;
if ( XL >= XND ) goto end;
break;
cout<<"Would you like to run the program again? (Y or N)";
cin>>ANSWER;
end:
return 0;
}
```