import static java.lang.Math.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import visad.*;
import visad.java3d.DisplayImplJ3D;
import visad.java2d.DisplayImplJ2D;
import java.rmi.RemoteException;
    class data
	{
	public double x[];	
	public data(double[] xi)
	{
	int n=xi.length;
	x=new double[n];
	for(int i=0;i<n;i++) {x[i]=xi[i];}
	}	
	public String toString() {return ""+x[0]+" "+x[1];}
	}
		
public class NA 
{    
	
public static double[] dataentry()
{
    String s=JOptionPane.showInputDialog("ENTER FIRST ROOT ESTIMATES WITH ONE EMPTY SPACE IN BETWEEN: ");        
    StringTokenizer token=new StringTokenizer(s);
    int n=token.countTokens()-1;
    int m=n+1;
    double a[]=new double[m];
    int j=0;           
    while(token.hasMoreTokens())
    {
    Double ax=new Double(token.nextToken());
    a[j++]=ax.doubleValue();
    }
    return a; 
}
	//graphic data output method : print (JTable output)
	public static void print(double a)
	{  double b[]=new double[1];
	   b[0]=a;
	   Text.printT(b);
    }
	
    public static void print(double a,String s)
	{  double b[]=new double[1];
	   String s1[]=new String[1];
	   s1[0]=s;
	   b[0]=a;
	   Text.printT(b,s1);
    }
    	
	public static void print(double a[][])
	{Text.printT(a);}
	
	public static void print(double a[][],String baslik[])
	{Text.printT(a,baslik);}
	
    public static void print(double a[][],String baslik[],String bb)
	{Text.printT(a,baslik,bb);}
	
	public static void print(double a[][],String bb)
	{Text.printT(a,bb);}
	
    public static void print(double a[])
	{Text.printT(a);}
	
	public static void print(double a[],String baslik[])
	{Text.printT(a,baslik);}
	
	public static void printT(double a[],String baslik[])
	{Text.print(a,baslik);}
	
    public static void print(double a[],String baslik[],String bb)
	{Text.printT(a,baslik,bb);}
	
	public static void print(double a[],String bb)
	{Text.printT(a,bb);}
	

//reading and writing data into SQLite database 
     public static double[][] runQuery(String databasename,String query,boolean print) throws IOException,ClassNotFoundException
     { return SQLite.query_double(databasename,query,print);}         
     public static double[][] loadSQL(String databasename, String tablei) throws IOException,ClassNotFoundException
     { return SQLite.read_double(databasename,tablei);}     
     public static double[][] loadSQL(String databasename, String tablei,String column[]) throws IOException,ClassNotFoundException
     { return SQLite.read_double(databasename,tablei,column);}     
     public static double[][] loadSQL(String databasename, String tablei,int column_no[]) throws IOException,ClassNotFoundException
     { return SQLite.read_double(databasename,tablei,column_no);}     
     public static void saveSQL(String databasename, String tablei,String column[],double a[][]) throws IOException,ClassNotFoundException
     { SQLite.write_double(databasename,tablei,column,a);}     
     public static void saveSQL(String databasename,String tablei,double a[][]) throws IOException,ClassNotFoundException
     { SQLite.write_double(databasename,tablei,a);}     
//reading and writing data into spreadsheet (xls)
     public static double[][] loadXLS(String filename, String pagetitle,String xy0,String xyn)
     { return excel.read_double_from_excel(filename,pagetitle,xy0,xyn);}
     public static double[][] loadXLS(String filename, int pageno,String xy0,String xyn)
     { return excel.read_double_from_excel(filename,pageno,xy0,xyn);}
     public static double[][] loadXLS(String filename, String pagetitle,String xy0,int nx)
     { return excel.read_double_from_excel(filename,pagetitle,xy0,nx);}     
     public static double[][] loadXLS(String filename, int pageno,String xy0,int nx)
     { return excel.read_double_from_excel(filename,pageno,xy0,nx);}
     public static void saveXLS(String filename, String pagetitle,String xy0,double a[][]) throws IOException
     {excel.write_double_to_excel(filename,pagetitle,xy0,a);}   
      public static void saveXLS(String filename, String pagetitle,double a[][]) throws IOException
     {excel.write_double_to_excel(filename,pagetitle,a);}
     public static void saveXLS(String filename,double a[][]) throws IOException
     {excel.write_double_to_excel(filename,a);}      
//reading and writing data from a text file     
     public static double[][] load(String filename) throws IOException
     {return inputdouble(filename); }             
     public static void save(String filename,double a[][]) throws IOException
     {    FileWriter fout = new FileWriter(filename);
          for(int i=0;i<a.length;i++)
          {for(int j=0;j<a.length;j++)
           {fout.write(a[i][j]+" ");}
            fout.write("\n");
           }
          fout.close();
     }
     public static double[][] inputdouble(String filename) throws IOException
     {
	 //reading double values from one line of data    
	 BufferedReader fin=new BufferedReader(new FileReader(filename));
     double a[][]=inputdouble(fin);
     return a;
     }
     public static void save(String filename,double a[]) throws IOException
     {    FileWriter fout = new FileWriter(filename);
          for(int j=0;j<a.length;j++)
           {fout.write(a[j]+" ");}
            fout.write("\n");
          fout.close();
     }          
    public static double[][] inputdouble(BufferedReader fin) throws IOException
    {
	 ArrayList<data> a=new ArrayList<data>();
	 int mmax=0;
	 double b[][];
	 int n=0,m=0;
	 String s1="";	 
	 try{
       while(fin!=null)
       { s1=fin.readLine();
       if(s1==null)break;
         StringTokenizer token=new StringTokenizer(s1);
         m=token.countTokens();
         if(m>mmax) mmax=m;
         double aa[]=new double[m];
         int j=0;           
         while(token.hasMoreTokens())
         { Double ax=new Double(token.nextToken());
           aa[j++]=ax.doubleValue();
         }
         data vx=new data(aa);
         a.add(vx);
       n++;
	   }
       } catch(EOFException e_eof)
          {
          //close ffile
          try{fin.close();
      } 
      catch(NullPointerException e) {}   
      catch(IOException e)
             {
             System.err.println("Error Closing File\n"+e.toString());
             System.exit(1);
             }
          } //End of EOFException
     b=new double[n][mmax];
     int k=0;
     Iterator<data> i=a.iterator();
     while(i.hasNext()) {data vx=i.next();b[k++]=vx.x;}
     double a1[][]=new double[b[0].length][b.length];
     for(int ii=0;ii<b[0].length;ii++)
     {for(int jj=0;jj<b.length;jj++)
       {a1[ii][jj]=b[jj][ii];}
     }
     return a1;
     }     
  
   //Function evaluations & creations
   public static String inputfunc()
   {inputA x0=new inputA();
    return x0.vericiktisi();
   }
      
   public static double[] setX(double xmin,double dx,double xmax)
   {
    int n=(int)((xmax-xmin)/dx+0.00000000000001);
    double x[]=new double[n+1];
    for(int i=0;i<=n;i++)
    {x[i]=xmin+dx*i;}
    x[n]=xmax;
    return x;	   
   }
   
   public static double[] setX(double xmin,double xmax,int n)
   {
    double dx=(xmax-xmin)/n;
    double x[]=new double[n+1];
    for(int i=0;i<=n;i++)
    {x[i]=xmin+dx*i;}
    x[n]=xmax;
    return x;	   
   }
   
   public static double[] setX(double xmin,double xmax)
   { int n=200;
    double dx=(xmax-xmin)/n;
    double x[]=new double[n+1];
    for(int i=0;i<=n;i++)
    {x[i]=xmin+dx*i;}
    x[n]=xmax;
    return x;	   
   }
    
   public static double[] setX(int xmin,int xmax)
   {
    int n=xmax-xmin;
    double x[]=new double[n+1];
    for(int i=0;i<=n;i++)
    {x[i]=xmin+i;}
    return x;	   
   }
   

   
   public static double[] feval(String function,double x[])
   {return setY(function,x);}
   
   public static double[] feval(f_x ff,double x[])
   {return setY(ff,x);}
   
   public static double feval(String function,double x)
   {return setY(function,x);}
   
   public static double feval(f_x ff,double x)
   { return ff.func(x);}
   
   public static double[] setY(String function,double x[])
   {
	ce1X x0=new ce1X(function);
	ce2T x1=new ce2T(x);
    double y[]=x1.r;
    return y;	   
   }
   
   public static double[] setY(f_x ff,double x[])
   {
    int n=x.length;;
    double y[]=new double[n];
    for(int i=0;i<n;i++)
    {y[i]=ff.func(x[i]);}
    return y;	   
   }
   
   public static double setY(String function,double x)
   {
	ce1X x0=new ce1X(function);
	ce2V x1=new ce2V(x);
    double y=x1.r;
    return y;	   
   }
   
   public static double setY(f_x ff,double x)
   { return ff.func(x);}
   
   public static double[] setY(String function,double xmin,double dx,double xmax)
   { double x[]=setX(xmin,dx,xmax);
	ce1X x0=new ce1X(function);
	ce2T x1=new ce2T(x);
    double y[]=x1.r;
    return y;	   
   }
   
   public static double[] func(String function,double x[])
   { return setY(function,x);}
   
   public static double[] func(String function,double xmin,double dx,double xmax)
   { return setY(function,xmin,dx,xmax);}
   
   //plot functions
   public static void plot(String function,double x[])
   { double y[]=setY(function,x);
     Plot pp=new Plot(x,y);
     pp.setPlabel("y = "+function);
     pp.plot();
   }
      
   public static void plot(double a[][])
   { Plot pp=new Plot(a[0],a[1]);
     pp.plot();
   }
   
   public static void plot(String function,double xmin,double dx,double xmax)
   { double x[]=setX(xmin,dx,xmax);
	 double y[]=setY(function,x);
     Plot pp=new Plot(x,y);
     pp.setPlabel("y = "+function);
     pp.plot();
   }
   
   public static void plot()
   {  ce1 x0=new ce1();
      double a[]=Text.readDoubleV("Enter minimum and maximum values of the function xmin xmax");
      ce3 x1=new ce3(a[0],a[1],400,x0.s);
   }
   
   public static void plot(double x[],double y[])
   { Plot.data(x,y);}
   
   public static void time_plot(String function,double xmin,double xmax,double tmin,double tmax)
   {    ce1DT x0=new ce1DT(function);
        double a[]={xmin,xmax,tmin,tmax};
        //double a[]=Text.readDoubleV("Fonksiyonun minimum ve maksimum dešerlerini giriniz : xmin xmax tmin tmax");
        ce3DT x1=new ce3DT(a,x0.s);
   }
   
   public static void contour_plot(String function,double xmin,double xmax,double ymin,double ymax)
   {    ce1DC x0=new ce1DC(function);
        double a[]={xmin,xmax,ymin,ymax};
        //double a[]=Text.readDoubleV("Fonksiyonun minimum ve maksimum dešerlerini giriniz xmin xmax  ymin ymax");
        ce3DC x1=new ce3DC(a,50,x0.s);
   }
   
   public static void plot3D(String function,double xmin,double xmax,double ymin,double ymax) throws RemoteException,VisADException
   {   ce5 xx=new ce5(function);
	   double a[]={xmin,xmax,ymin,ymax};
	   ce6 xy=new ce6(xmin,xmax,ymin,ymax,200); 
   }
   
   public static double[][] setY(String function[],double x[])
   {
	cei x0=new cei(function);
    int m=function.length;
    ce2S x1=new ce2S(m,x);
    double z[][]=x1.r;  
    return z;	   
   }
   
   public static double[][] setY(String function[],double xmin,double dx,double xmax)
   { double x[]=setX(xmin,dx,xmax);
	 cei x0=new cei(function);
     int m=function.length;
     ce2S x1=new ce2S(m,x);
     double z[][]=x1.r;  
     return z; 
   }
   
   public static double[][] func(String function[],double x[])
   { return setY(function,x);}
   
   public static double[][] func(String function[],double xmin,double dx,double xmax)
   { return setY(function,xmin,dx,xmax);}
   
   public static void plot(String function[],double xmin,double dx,double xmax)
   { double x[]=setX(xmin,dx,xmax);
	 double y[][]=setY(function,x);
	 Plot.data(x,y);}
   
   public static void plot(String function[],double x[])
   { double y[][]=setY(function,x);Plot.data(x,y);}
   
   public static void plot(double x[],double y[][])
   { Plot.data(x,y);}
   //root of a simple function
//Bisection method f_x function input
public static double bisection(f_x f,double xl,double xu)
{return ce2.bisection(f,xl,xu);}
//Bisection method String defined function
public static double bisection(String function,double xl,double xu)
{	ce1X x0=new ce1X(function);
    ce2 x1=new ce2(xl,xu); 
	return x1.r;	
}

//Newton method String defined function
public static double newton(String function,double x)
{
    ce1X x0=new ce1X(function);
    ce2C x1=new ce2C(x); 
	return x1.r;		
}
//Newton method f_x function input
public static double newton(f_x f,double xl)
{return ce2C.newton(f,xl);}
//Halley method String defined function input
public static double halley(String function,double x)
{
    ce1X x0=new ce1X(function);
    ce2C1 x1=new ce2C1(x); 
	return x1.r;		
}
//Halley method f_x function input
public static double halley(f_x f,double xl)
{return ce2C1.halley(f,xl);}
//Abbasbandy method String defined function input
public static double abbasbandy(String function,double x)
{
    ce1X x0=new ce1X(function);
    ce2C2 x1=new ce2C2(x); 
	return x1.r;		
}
//Halley method abstract f_x defined function input
public static double abbasbandy(f_x f,double xl)
{return ce2C2.abbasbandy(f,xl);}
//Thiele 1  method String defined function input
public static double TM1(String function,double x)
{  //Thiele 1 method
    ce1X x0=new ce1X(function);
    ce2C3 x1=new ce2C3(x); 
	return x1.r;		
}
//Thiele 1  method  f_x defined function input
public static double TM1(f_x f,double xl)
{  //Thiele 1 method
	return ce2C3.TM1(f,xl);}
//Thiele 2  method String defined function input
public static double TM2(String function,double x)
{    //Thiele 2 method
    ce1X x0=new ce1X(function);
    ce2C4 x1=new ce2C4(x); 
	return x1.r;		
}
//Thiele 2  method f_x defined function input
public static double TM2(f_x f,double xl)
{ //Thiele 2 method
return ce2C4.TM2(f,xl);}
//Hasan 47a  method   String defined function input
public static double hasan(String function,double x)
{    //Hasan47a method
    ce1X x0=new ce1X(function);
    ce2C5 x1=new ce2C5(x); 
	return x1.r;		
}
//Hasan 47a  method  f_x defined function input
public static double hasan(f_x f,double xl)
{ //Thiele 2 method
return ce2C5.hasan47a(f,xl);
}
// secant String defined function input
public static double secant(String function,double x)
{   ce1X x0=new ce1X(function);
    ce2C xA=new ce2C(x); 
	return xA.r;		
}
//Mathlab name fzero adjusted newton method
public static double fzero(String function,double x)
{return newton(function,x);	}
//Mathlab name fzero adjusted newton method
public static double fzero(f_x ff,double x)
{return ce2C.newton(ff,x);	}
//Brent method
public static double brent(String function,double x1,double x2)
{   ce1X x0=new ce1X(function);
    ce2F xA=new ce2F(x1,x2); 
	return xA.r;
}
//False position (Regula falsi) method
public static double false_position(String function,double x1,double x2)
{
    ce1X x0=new ce1X(function);
    ce2A xA=new ce2A(x1,x2); 
	return xA.r;
}
//Stephensen method
public static double stephensen(String function,double x1)
{   ce1X x0=new ce1X(function);
    ce2B xA=new ce2B(x1); 
	return xA.r;
}
//Brent method
public static double brent(f_x f,double x1,double x2)
{return ce2F.brent(f,x1,x2);}
//Ridder method
public static double ridder(f_x f,double xmin,double xmax)
{       return ce2E.ridder(f,xmin,xmax);}

public static double ridder(String function,double xmin,double xmax)
{       ce1X x0=new ce1X(function);
        ce2E x1=new ce2E(xmin,xmax);
        return x1.r;
}
//Inverse interpolation method
public static double inverseinterpolation(String function,double xmin,double x2,double xmax)
{       ce1X x0=new ce1X(function);
        ce2I x1=new ce2I(xmin,x2,xmax);
        return x1.r;
}
public static double inverseinterpolation(f_x f,double xmin,double x2,double xmax)
{       return ce2I.inverseinter2Droot(f,xmin,x2,xmax);}
//Muller method
public static double muller(String function,double xmin,double x2,double xmax)
{       ce1X x0=new ce1X(function);
        ce2G x1=new ce2G(xmin,x2,xmax);
        return x1.r;
}
public static double muller(f_x f,double xmin,double x2,double xmax)
{       return ce2G.muller(f,xmin,x2,xmax);}
//Newton-bisection
public static double newton_bisection(String function,double xmin,double xmax)
{       ce1X x0=new ce1X(function);
        ce2H x1=new ce2H(xmin,xmax);
        return x1.r;
}
public static double newton_bisection(f_x f,double xmin,double xmax)
{       return ce2H.newton_bisection(f,xmin,xmax);
}
//cubic roots
public static double[][] cubic_roots(double d[])
{return NA13D.cubic_roots(d);}
//========================System of linear equations
public static double[] gauss(double a[][],double b[])
{return NA15.pivotlugauss(a,b);}

public static double[] gaussjordan(double a[][],double b[])
{  return NA17.gaussjordan(a,b);}
//Gauss-Doolittle LU decompose
public static double[][] gaussLU(double ai[][])
{return NA18.gaussLU(ai);}
public static double[] gauss_back_substitution(double ai[][],double bi[])
{return NA18.yerine_koyma(ai,bi);}
//Craut LU
public static double[][] crautLU(double c[][])
{return NA20.crautLU(c);}
public static double[] craut_back_substitution(double ai[][],double bi[])
{return NA20.back_substitution(ai,bi);}
//Gauss-seidel
public static double [] gauss_seidel(double a[][],double b[],double x[])
{return NA21.gauss_seidel(a,b,x);}
public static double [] gauss_seidel(double a[][],double b[])
{return NA21.gauss_seidel(a,b);}
//Thomas algorithm 3-band matrix
public static double [] thomas(double a[][],double r[])
{return NA23.thomas(a,r);}
//5 band matrix
public static double [] fiveband(double A[][],double b[])
{return  NA24.fiveband(A,b);}
//Conjugate gradient
public static double[] conjugate_gradient(double A[][],double b[])
{return NA25.conjugate_gradient(A,b);}
public static double[] conjugate_gradient(double x[],double A[][],double b[])
{return NA25.conjugate_gradient(x,A,b);}
public static double[] conditioned_conjugate_gradient(double A[][],double b[])
{return NA26.conjugate_gradient(A,b);}
public static double[] conditioned_conjugate_gradient(double x[],double A[][],double b[])
{return NA26.conjugate_gradient(x,A,b);}

//Residial correction
public static double[] residual_correction(double a[][],double b[],double eps)
{return residual.residual_correction(a,b,eps);}
//Singular value decomposition
public static double[] SVD(double a[][],double b[])
{return SVD.solve(a,b);}
//========== finding optimum
public static double golden(f_x f,double a,double b,double epsilon)
{return golden(f,a,b,epsilon,1.0e-10,0);}

public static double golden(f_x f,double a,double b)
{return golden(f,a,b,1.0e-10,1.0e-10,0);}

public static double fmin(f_x f,double a,double b)
{return golden(f,a,b,1.0e-10,1.0e-10,0);}

public static double golden(String function,double a,double b)
{   ce1X x0=new ce1X(function);
	f2D ff=new f2D();	
	ce2J xA=new ce2J(a,b);
	return xA.r;
}

public static double fmin(String function,double a,double b)
{   ce1X x0=new ce1X(function);
	f2D ff=new f2D();	
	ce2J xA=new ce2J(a,b);
	return xA.r;
}

public static double golden(f_x f,double a,double b,double epsilon,double delta,int print)
{
return ce2J.golden(f,a,b,epsilon,delta,print);
}

public static double newton_opt(f_x f,double x)
{ 
// minimum finding by  newton-raphson method
int nmax=500;
double tolerance=1.0e-15;
double fx,dfx;
for(int i=0;i<nmax;i++)
{
fx=f.dfunc(x,1,1e-4);
dfx=f.dfunc(x,2,1.0e-4);
x-=fx/dfx;
if(Math.abs(fx)<tolerance)
{
return x;
}
}
return x;
}

public static double newton_opt(String function,double x)
{
// minimum finding by  newton-raphson method
    ce1X x0=new ce1X(function);
	ce2M xA=new ce2M(x);
	return xA.r;
}

public static double quadratic_poly_opt(String function,double x1,double x2)
{
// minimum finding by  quadratic polynomial search method
    ce1X x0=new ce1X(function);
	ce2K xA=new ce2K(x1,x2);
	return xA.r;
}

public static double cubic_opt(String function,double x1,double x2)
{
// minimum finding by  cubic search method
    ce1X x0=new ce1X(function);
	ce2L xA=new ce2L(x1,x2);
	return xA.r;
}
public static double brent_opt(String function,double x1,double x2,double x3)
{
// minimum finding by  brent method
    ce1X x0=new ce1X(function);
	ce2N xA=new ce2N(x1,x2,x3);
	return xA.r;
}
//Multicomponent optimisation

public static double[] newton_opt(String function,double x[])
{ ce5_1 xo=new ce5_1(function);
  ce3_6 x1=new ce3_6(x);
  return x1.r;
}
public static double[] nelder_opt(String function,double x[])
{ ce5_1 xo=new ce5_1(function);
  ce3_7 x1=new ce3_7(x);
  return x1.r;
}
public static double[] steepest_descent_opt(String function,double x[])
{ ce5_1 xo=new ce5_1(function);
  ce3_8 x1=new ce3_8(x);
  return x1.r;
}
public static double[] dampednewton_opt(String function,double x[])
{ ce5_1 xo=new ce5_1(function);
  ce3_9 x1=new ce3_9(x);
  return x1.r;
}
public static double[] fletcher_reeves_opt(String function,double x[])
{ ce5_1 xo=new ce5_1(function);
  ce3_10 x1=new ce3_10(x);
  return x1.r;
}
public static double[] polak_ribiere_opt(String function,double x[])
{ ce5_1 xo=new ce5_1(function);
  ce3_11 x1=new ce3_11(x);
  return x1.r;
}
public static double[] davidon_fletcher_powell_opt(String function,double x[])
{ ce5_1 xo=new ce5_1(function);
  ce3_12 x1=new ce3_12(x);
  return x1.r;
}

//Broyden - Fletcher-Goldberg-Shanno (BFGS)
public static double[] BFGS_opt(String function,double x[])
{ ce5_1 xo=new ce5_1(function);
  ce3_13 x1=new ce3_13(x);
  return x1.r;
}
//Homotophy or continuation method with Runge Kutta 6
public static double[] continuation_opt(String function,double x[])
{ ce5_1 xo=new ce5_1(function);
  ce3_14 x1=new ce3_14(x);
  return x1.r;
}
//Newton Raphson and Homotophy or continuation method with Runge Kutta 4
public static double[] newton_continuation_opt(String function,double x[])
{ ce5_1 xo=new ce5_1(function);
  ce3_15 x1=new ce3_15(x);
  return x1.r;
}
//Broyden (secant) optimizasyon method
public static double[] broyden_opt(String function,double x[])
{ ce5_1 xo=new ce5_1(function);
  ce3_16 x1=new ce3_16(x);
  return x1.r;
}
//Genetic algorithms 1
public static double[] GA_opt(String function,double xmin[],double xmax[])
{ ce5_1 xo=new ce5_1(function);
  ce3_17 x1=new ce3_17(xmin,xmax);
  return x1.r;
}
// solution of non-linear system of equations
public static double[] newton(String function[],double x1[])
{
// system of equation by Newton's method
    cefixi x0=new cefixi(function);
	ce3_1 xA=new ce3_1(x1);
	return xA.r;
}

public static double[] newton(fi_xi f,double x1[])
{
// system of nonlinear equation by Newton's method
	return ce3_1.newton(f,x1);
}
public static double[] newton(double x1[])
{
// system of equation by Newton's method
    cefixi x0=new cefixi();
	ce3_1 xA=new ce3_1(x1);
	return xA.r;
}
//Broyden (Secant ) method

public static double[] broyden(String function[],double x1[])
{
// system of equation by Newton's method
    cefixi x0=new cefixi(function);
	ce3_2 xA=new ce3_2(x1);
	return xA.r;
}

public static double[] broyden(fi_xi f,double x1[])
{
// system of equation by Broyden's method
	return NA30A.broyden(f,x1);
}

public static double[] broyden(double x1[])
{
// system of equation by Newton's method
    cefixi x0=new cefixi();
	ce3_2 xA=new ce3_2(x1);
	return xA.r;
}
// Continuation (Homotophy) method
public static double[] continuationRK4(String function[],double x1[])
{
    //system of equation by Continuation(Homotophy) method Runge Kutta 4
    cefixi x0=new cefixi(function);
	ce3_2 xA=new ce3_2(x1);
	return xA.r;
}

public static double[] continuationRK4(fi_xi f,double x1[])
{
    // system of equation by Continuation(Homotophy) method Runge Kutta 4
	return NA30B1. continuationRK4(f,x1,4);
}

public static double[] continuationRK4(double x1[])
{
    //system of equation by Continuation(Homotophy) method Runge Kutta 4
    cefixi x0=new cefixi();
	ce3_3 xA=new ce3_3(x1);
	return xA.r;
}

public static double[] continuationRK6(String function[],double x1[])
{
    //system of equation by Continuation(Homotophy) method Runge Kutta 4
    cefixi x0=new cefixi(function);
	ce3_3 xA=new ce3_3(x1);
	return xA.r;
}

public static double[] continuationRK6(fi_xi f,double x1[])
{
    // system of equation by Continuation(Homotophy) method Runge Kutta 4
	return NA30B1. continuationRK6(f,x1,4);
}

public static double[] continuationRK6(double x1[])
{
    //system of equation by Continuation(Homotophy) method Runge Kutta 4
    cefixi x0=new cefixi();
	ce3_4 xA=new ce3_4(x1);
	return xA.r;
}

public static double[] newton_continuationRK4(String function[],double x1[])
{
    //system of equation by Continuation(Homotophy) method Runge Kutta 4
    cefixi x0=new cefixi(function);
	ce3_5 xA=new ce3_5(x1);
	return xA.r;
}

public static double[] newton_continuationRK4(fi_xi f,double x1[])
{
    // system of equation by Continuation(Homotophy) method Runge Kutta 4
	return NA30B1.newton_continuationRK4(f,x1);
}

public static double[] newton_continuationRK4(double x1[])
{
    // System of equation by Continuation (Homotophy) method Runge Kutta 4
    cefixi x0=new cefixi();
	ce3_5 xA=new ce3_5(x1);
	return xA.r;
}

//Least square curve fitting
//===========Integral =============
public static double[][] gauss_legendre_coefficients(double x1,double x2,int n)
{
	//calculates legendre gauss-coefficients as coefficients of the integral
	//for n terms
	double EPS=3.0e-15;
	int m,j,i;
	double z1,z,xm,xl,pp,p3,p2,p1;
    //double x[]=new double[n];
    //double w[]=new double[n];
    double a[][]=new double[2][n];//a[0][i]=x[i]   a[1][i]=w[i]
	m=(n+1)/2;
	xm=0.5*(x2+x1);
	xl=0.5*(x2-x1);
	for (i=1;i<=m;i++)  {
		z=Math.cos(Math.PI*((i-0.25)/(n+0.5)));
		do {
			p1=1.0;
			p2=0.0;
			for (j=1;j<=n;j++) {
				p3=p2;
				p2=p1;
				p1=((2.0*j-1.0)*z*p2-(j-1.0)*p3)/j;
			}
			pp=n*(z*p1-p2)/(z*z-1.0);
			z1=z;
			z=z1-p1/pp;
		} while (Math.abs(z-z1) > EPS);
		a[0][i-1]=xm-xl*z;
		a[0][n-i]=xm+xl*z;
		a[1][i-1]=2.0*xl/((1.0-z*z)*pp*pp);
		a[1][n-i]=a[1][i-1];
			}
return a;
}

public static double integral(f_x f_xnt,double x1,double x2,int n)
{
//n : number of integral coefficients
// this routine first generates gauss legendre coefficients
// for [x1,x2] band 
// then calculates gauss legendre integral
double a[][]=new double[2][n];
a=gauss_legendre_coefficients(x1,x2,n);
Text.print(Text.T(a));
//System.out.println(Matrix.toString(a));
double z=0;
for(int i=0;i<n;i++)
{ z+=a[1][i]*f_xnt.func(a[0][i]);}
return z;
}

public static double integral(String function,double x1,double x2)
{ //Gauss-Legendre
ce1X x0=new ce1X(function);
ce2O xA=new ce2O(x1,x2);
return xA.r;
}
public static double Gauss_Legendre_integral(double x1,double x2)
{       ce1 x0=new ce1();
        ce2O xx=new ce2O(x1,x2);
        return xx.r;
}
//Adaptive Gauss-Lobatto Integral
public static double Gauss_Lobatto_integral(double x1,double x2)
{       ce1 x0=new ce1();
        ce2P xx=new ce2P(x1,x2);
        return xx.r;
}

public static double Gauss_Lobatto_integral(String function,double x1,double x2,int n)
{ //Gauss-Lobatto
ce1X x0=new ce1X(function);
ce2P xA=new ce2P(x1,x2);
return xA.r;
}
public static double adaptive_Lobatto_integral(String function,double x1,double x2,int n)
{ //Gauss-Lobatto
ce1X x0=new ce1X(function);
ce2Q xA=new ce2Q(x1,x2);
return xA.r;
}
public static double adaptive_Kronrad_integral(String function,double x1,double x2,int n)
{ 
ce1X x0=new ce1X(function);
ce2R xA=new ce2R(x1,x2);
return xA.r;
}
public static double quad(f_x f_xnt,double x1,double x2)
{ return integral(f_xnt,x1,x2,20);}

public static double quad(String function,double x1,double x2)
{ ce1X x0=new ce1X(function);
  ce2R xA=new ce2R(x1,x2);
  return xA.r;
}
//DIFFERENTIAL GROUP
public static double derivative(String function,double x1)
{       ce1X x0=new ce1X(function);
        f2D ff=new f2D();
        double r=ff.dfunc(x1);
        return r;
}
//nth order derivative
public static double derivative_n(String function,double x1,int n)
{       ce1X x0=new ce1X(function);
         f2D ff=new f2D();
        double r=ff.dfunc(x1,n);
        return r;
}
//=================================
}