import static java.lang.Math.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
@FunctionalInterface
interface cf_xi 
{     
public complex func(complex x[]);
//conversion method if_x to f_x(abstract class)

default public complex dfunc(complex x[],int i)
  { // complex sayısal türev fonksiyonu
   int n=x.length;
   System.out.println("n="+n);
   complex x1[]=new complex[n];
   complex xah[]=new complex[n];
   complex xa2h[]=new complex[n];
   complex xeh[]=new complex[n];
   complex xe2h[]=new complex[n];
   complex fah=new complex();
   complex fa2h=new complex();
   complex feh=new complex();
   complex fe2h=new complex();
   complex df=new complex();
   for(int j=0;j<n;j++)
   {x1[j]=new complex(x[j]);
    xah[j]=new complex(x[j]);
    xa2h[j]=new complex(x[j]);
    xeh[j]=new complex(x[j]);
    xe2h[j]=new complex(x[j]);    
   }
   double hh1=0.001563465314;
   double hh2=0.0011173874;
   complex h=new complex(hh1,hh2);
   complex he=new complex(-hh1,-hh2);
   complex h2=new complex(2.0*hh1,2.0*hh2);
   complex he2=new complex(-2.0*hh1,-2.0*hh2);
   xah[i]=complex.add(x1[i],h);
   xa2h[i]=complex.add(x1[i],h2);
   xeh[i]=complex.add(x1[i],he);
   xe2h[i]=complex.add(x1[i],he2);
   feh=complex.multiply(func(xeh),(-8.0/12.0));
   fe2h=complex.multiply(func(xe2h),(1.0/12.0));   
   fah=complex.multiply(func(xah),(8.0/12.0));
   fa2h=complex.multiply(func(xa2h),(-1.0/12.0));
   df=complex.add(fe2h,complex.add(feh,complex.add(fah,fa2h)));
   df=complex.divide(df,h);
   return df;
  }
  
default public complex[] dfunc(complex x[])
{int n=x.length;
 complex deriv[]=new complex[n];
 for(int i=0;i<n;i++)
 {deriv[i]=dfunc(x,i);}
 return deriv;
}

}

