def compute_K_analytical(dataframe, spacing):
    """Given an electrode spacing, compute geometrical factors using the
    equation for the homogeneous half-space (Neumann-equation)

    If a dataframe is given, use the column (a, b, m, n). Otherwise, expect an
    Nx4 arrray.

    Parameters
    ----------
    dataframe : pandas.DataFrame or numpy.ndarray
        Configurations, either as DataFrame
    spacing : float or numpy.ndarray
        distance between electrodes. If array, then these are the x-coordinates
        of the electrodes
    """
    if isinstance(dataframe, pd.DataFrame):
        configs = dataframe[['a', 'b', 'm', 'n']].values
    else:
        configs = dataframe

    r_am = np.abs(configs[:, 0] - configs[:, 2]) * spacing
    r_an = np.abs(configs[:, 0] - configs[:, 3]) * spacing
    r_bm = np.abs(configs[:, 1] - configs[:, 2]) * spacing
    r_bn = np.abs(configs[:, 1] - configs[:, 3]) * spacing

    K = 2 * np.pi / (1 / r_am - 1 / r_an - 1 / r_bm + 1 / r_bn)

    if isinstance(dataframe, pd.DataFrame):
        dataframe['k'] = K

    return K