def backtrackingstep(x, xprev, f, gradf, proj, i):
    """a step method which uses backtracking linesearch

    Args:
        x: current iterate
        xprev: previous iterate (not used)
        f: function
        gradf: gradient of the function
        proj: projection method
        i: iteration number

    Returns:
        next iterate and function value at iterate
    """
    gradfx = gradf(x)
    t = 1
    a = 0.9
    step = proj(x + t*gradfx)
    i = 0
    fstep = f(step)
    while (fstep < f(x)+0.0004*t*gradfx.dot(gradfx)) and (i<100):
        t = t*a
        i = i+1
        step = proj(x + t*gradfx)
        fstep = f(step)
    return step, fstep