def polynomial(x, y, z, n):
    """used for interpolation

    Parameters
    ----------
    x : ndarray
        the integer values from 0 through n-1 inclusive (but float64)
    y : ndarray
        a 2-D array, axis 0 of length n
    z : float
        n / 2.
    n : int
        1 + order of polynomial fit
    """
    t = n * [0.0]
    for k in range(n):
        t[k] = y[k]
        for j in range(k - 1, -1, -1):
            t[j] = t[j + 1] + (t[j + 1] - t[j]) / ((z - x.item(j)) / (z - x
                .item(k)) - 1.0)
    return t[0]
