import java.io.*;
import javax.swing.*;
import javax.tools.*;
import java.util.*;
import java.lang.Integer;
import java.awt.*;
import java.awt.event.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.awt.image.*;
import javax.swing.*;
import java.util.Locale;
import java.text.*;
import java.util.*;
import javax.swing.table.*;
package Plot;
class ce2C
{ 	 public double r;	
	 public ce2C(double x1) 
	 {     
        f2D ff=new f2D();
        r= newton1(ff,x1);
     }

public static double newton1(f_x f,double x)
{
int nmax=500;
double h=1.0e-3;
double hh=1.0/h;
double tolerance=1.0e-8;
double fx,dfx,fxm,dfxm,d2fx;

for(int i=0;i<nmax;i++)
{  fx=f.func(x);
   fxm=f.func(x-h);
   dfx=(-f.func(x+2.0*h)+8.0*f.func(x+h)-8.0*f.func(x-h)+f.func(x-2.0*h))/12.0*hh;
   d2fx=(-f.func(x+2.0*h)+16.0*f.func(x+h)-30.0*f.func(x)+16.0*f.func(x-h)-f.func(x-2.0*h))/(12.0)*hh*hh;
   x-=fx*dfx/(dfx*dfx-fx*d2fx);
  if(Math.abs(fx)<tolerance) { return x;}
}
JOptionPane.showMessageDialog(null,"Maximum number of iterations are exceeded \n"+
   " Result mAy not be valid","MAXIMUM ITERATION NUMBER WARNING",JOptionPane.WARNING_MESSAGE);
return x;
}
}
