public static double process_F64 ( double sample , double x [ ] , double y [ ] , int i0 , int i1 ) { double result = 0 ; for ( int i = i0 ; i <= i1 ; i ++ ) { double numerator = 1.0 ; for ( int j = i0 ; j <= i1 ; j ++ ) { if ( i != j ) numerator *= sample - x [ j ] ; } double denominator = 1.0 ; double a = x [ i ] ; for ( int j = i0 ; j <= i1 ; j ++ ) { if ( i != j ) denominator *= a - x [ j ] ; } result += ( numerator / denominator ) * y [ i ] ; } return result ; }
UsingLlangrange s formula it interpulates the value of a function at the specified sample point given discrete samples . Which samples are used and the order of the approximation are given by i0 and i1 .