def hill_eq_brentq(xvalues_for_curve, hill_constants, y_value_curve_center):
    """ Residual function for the four parameter sigmoidal Hill equation.

    For further detail on the Hill equation, see the relevant docstring for hill_eq.

    y = hill_eq(x) - y_value_curve_center

    Parameters
    ----------
    xvalues_for_curve : array
        Numpy array of >250 x-values between the lowest and highest dose.
    hill_constants : tuple
        Tuple of the four parameters : upper, lower, EC50 and hillslope
    y_value_curve_center : array
        Represents the y-value of the curve. The difference between this and the real y-value from experimental
        data (e.g. y_orig_norm) is used to optimise the fit of the curve to the data.

    Returns
    -------
    y - y_value_curve_center : array
        Array that approaches zero, when an optimum fit is found.
    """
    upper, lower, EC50, hillslope = hill_constants
    y = upper + (lower-upper)/(1+(xvalues_for_curve/EC50)**-hillslope)
    return y - y_value_curve_center