function to interpolate the given data points using Lagrange 's formula xi corresponds to the new data point whose value is to be obtained n represents the number of known data points
static double interpolate ( Data f [ ] , int xi , int n ) {