private double [ ] extrapinterpolate ( double [ ] array ) { int n = array . length ; double [ ] d = new double [ n + 1 ] ; //end points from linear extrapolation //equations confirmed by Christopher Lindholm d [ 0 ] = 1.5 * array [ 0 ] - 0.5 * array [ 1 ] ; d [ n ] = 1.5 * array [ n - 1 ] - 0.5 * array [ n - 2 ] ; //inner points from simple average for ( int i = 1 ; i < n ; i ++ ) { d [ i ] = 0.5 * ( array [ i - 1 ] + array [ i ] ) ; } return d ; }
Add one element to the array by linear interpolation and extrapolation at the ends .