def _update_coefs(x, tau, gradfx, prox, f, g, beta, fk):
    """Non-monotone line search

    parameters
    ----------
    x: ndarray
        current coefficients
    tau: float
        step size
    gradfx: ndarry
        gradient operator evaluated at current coefficients
    prox: function handle
        proximal operator of :math:`g(x)`
    f: callable
        smooth differentiable function, :math:`f(x)`
    g: callable
        non-smooth function, :math:`g(x)`
    beta: float
        backtracking parameter
    fk: float
        maximum of previous function values

    returns
    -------
    z: ndarray
        next coefficients
    """
    x_hat = x - tau * gradfx
    z = prox(x_hat, tau)
    fz = f(z)
    count = 0
    while fz > fk + (gradfx * (z - x)).sum() + ((z - x) ** 2).sum() / (2 * tau
        ):
        count += 1
        tau = beta * tau
        x_hat = x - tau * gradfx
        z = prox(x_hat, tau)
        fz = f(z)
    sg = (x_hat - z) / tau
    return z, fz, sg, tau, count
