def partial(f, k, w):
    """ Return the partial derivative of the function ``f`` with
    respect to the ``k``th variable, at location ``w``.  Note that
    ``f`` must take a numpy array as input, and the partial derivative
    is evaluated with respect to the ``k``th element in that array.
    Similarly, ``w`` is a numpy array which can be used as input to
    ``f``."""
    w_plus, w_minus = w.copy(), w.copy()
    w_plus[k] += 0.01 # using epsilon = 0.01
    w_minus[k] += -0.01
    return (f(w_plus)-f(w_minus))/0.02