The example uses problem 1. a. from the same page:
int i, j;
int n = 4;
double X; //X will be used to approximate f(X).
double x[n]; //The x values.
double y[n]; //The y or f(x) values.
double Q[n][n]; //The output table.
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
Q[i][j] = 0.0; //Initializing the Q matrix to 0.
//Hardcoding the x and y values from problem 1. a.
x[0] = 8.1;
x[1] = 8.3;
x[2] = 8.6;
x[3] = 8.7;
y[0] = 16.94410;
y[1] = 17.56492;
y[2] = 18.50515;
y[3] = 18.82091;
X = 8.4; //Want to approximate f(X), or f(8.4).
for (i = 0; i < n; i++)
Q[i][0] = y[i]; //Setting the first column of Q to y[0] through y[3].
//Neville's method.
for (i = 1; i < n; i++) {
for (j = 1; j <= i; j++) {
Q[i][j] = ((X ‐ x[i ‐ j])*(Q[i][j ‐ 1])
‐ (X ‐ x[i])*(Q[i ‐ 1][j ‐ 1]))/(x[i] ‐ x[i ‐ j]);
}
}
printf("Resultant Q matrix:\n");
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
printf("%9f ", Q[i][j]);
}
printf("\n");
}