public static double polynomialDistance(double[] coeffs1,double[] coeffs2){
  if (coeffs1 == null || coeffs2 == null)   throw new NullPointerException("Received null argument");
  if (coeffs1.length != coeffs2.length)   throw new IllegalArgumentException("Can only compare polynomials with same order");
  double dist=0;
  int order=coeffs1.length - 1;
  for (int i=0; i <= order; i++) {
    dist+=(coeffs1[order - i] - coeffs2[order - i]) / (i + 1);
  }
  return Math.abs(dist);
}

public static double polynomialDistance ( double [ ] coeffs1 , double [ ] coeffs2 ) { if ( coeffs1 == null || coeffs2 == null ) throw new NullPointerException ( "Received null argument" ) ; if ( coeffs1 . length != coeffs2 . length ) throw new IllegalArgumentException ( "Can only compare polynomials with same order" ) ; double dist = 0 ; int order = coeffs1 . length - 1 ; for ( int i = 0 ; i <= order ; i ++ ) { dist += ( coeffs1 [ order - i ] - coeffs2 [ order - i ] ) / ( i + 1 ) ; } return Math . abs ( dist ) ; }
compute the integrated distance between two polynomials of same order . more precisely , this will return the absolute value of the integral from 0 to 1 of the difference between the two functions .
