public static void polcoe(final double[] x, final double[] y, final double[] cof){
    int k,j,i,n=x.length;
    double phi,ff,b;
    double[] s = new double[n];
    for (i=0;i<n;i++) s[i]=cof[i]=0.0;
    s[n-1]= -x[0];
    for (i=1;i<n;i++) {
      for (j=n-1-i;j<n-1;j++)
        s[j] -= x[i]*s[j+1];
      s[n-1] -= x[i];
    }
    for (j=0;j<n;j++) {
      phi=n;
      for (k=n-1;k>0;k--)
        phi=k*s[k]+x[j]*phi;
      ff=y[j]/phi;
      b=1.0;
      for (k=n-1;k>=0;k--) {
        cof[k] += b*ff;
        b=s[k]+x[j]*b;
      }
    }
  }