def METHOD_NAME(cost_name, ndim, method_name, x0):
    cost_function, cost_function_prime, hessian = mk_costs(ndim)[0][cost_name]
    method = methods[method_name]
    f_prime = CountingFunction(cost_function_prime)
    f = LoggingFunction(cost_function, counter=f_prime.counter)
    method(f, x0, jac=f_prime)
    this_costs = np.array(f.all_f_i)
    return this_costs, np.array(f.counts)