Appendix III

AFGEN function

The AFGEN function, which interpolates linearly between the points of a table.

AFGEN stands for Arbitrary Function GENerator (Subroutine AFGen). It is a function which is used for linear interpolation in a one-dimensional array with paired data. Uneven places in the array represent the X-values, whereas the Y-values are represented by the even places. Such an array can describe the dependency of variable Y on variable X when no mathematical description is available or is too cumbersome. A plotted example is depicted in Figure AIII_1:

Linear interpolation example: four points (x1, y1) to (x4, y4) plotted with Y-values on the vertical axis and X-values on the horizontal axis, joined by straight line segments that get steeper to the right, with x3 and x4 close together.
Figure AIII.1. Linear interpolation

The array belonging to this example has to be filled as:

Place(1)(2)(3)(4)(5)(6)(7)(8)
ValueX1Y1X2Y2X3Y3X4Y4

Arguments of the AFGEN function in order of their place in the argument list are: name of the table, number of pairs, X value to be interpolated. The X-values have to be arranged from low to high values and are not allowed to be interchanged. Every X-value has to precede its connected Y-value.

Three situations for interpolation can occur:

\1) The argument x at which interpolation should take place is less or equal to the first X-value in the array. The Y-value is set to the first Y-value in the array.

\2) The argument x value at which interpolation should take place is between the first and the last X-value in the array. The Y-value can now be found via linear interpolation. First the X values left and right from the argument x have to be detected, then the Y-value can be calculated:

y=Yn−1+(x−Xn−1) Yn−Yn−1Xn−Xn−1y = Y_{n-1} + (x - X_{n-1})\,\frac{Y_n - Y_{n-1}}{X_n - X_{n-1}}

\3) The argument x at which interpolation should take place is equal to or larger then the last X-value in the array. The Y-value is set to the last Y-value in the array.