for (int i = 1; i < n; i++) {
for (int j = 0; j < n-i; j++) {
final double denominator = x[j+i] - x[j];
if (denominator == 0.0) {
// This happens only when two abscissas are identical.
throw new DuplicateSampleAbscissaException(x[j], j, j+i);
}
divdiff[j] = (divdiff[j+1] - divdiff[j]) / denominator;
}
a[i] = divdiff[0];
}