def minimize(f, start=None, smooth=False, log=None, array=False, **vargs):
if start is None:<EOL><INDENT>assert not array, "<STR_LIT>"<EOL>arg_count = f.__code__.co_argcount<EOL>assert arg_count > <NUM_LIT:0>, "<STR_LIT>"<EOL>start = [<NUM_LIT:0>] * arg_count<EOL><DEDENT>if not hasattr(start, '<STR_LIT>'):<EOL><INDENT>start = [start]<EOL><DEDENT>if array:<EOL><INDENT>objective = f<EOL><DEDENT>else:<EOL><INDENT>@functools.wraps(f)<EOL>def objective(args):<EOL><INDENT>return f(*args)<EOL><DEDENT><DEDENT>if not smooth and '<STR_LIT>' not in vargs:<EOL><INDENT>vargs['<STR_LIT>'] = '<STR_LIT>'<EOL><DEDENT>result = optimize.minimize(objective, start, **vargs)<EOL>if log is not None:<EOL><INDENT>log(result)<EOL><DEDENT>if len(start) == <NUM_LIT:1>:<EOL><INDENT>return result.x.item(<NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>return result.x<EOL><DEDENT>
Minimize a function f of one or more arguments.

    Args:
        f: A function that takes numbers and returns a number

        start: A starting value or list of starting values

        smooth: Whether to assume that f is smooth and use first-order info

        log: Logging function called on the result of optimization (e.g. print)

        vargs: Other named arguments passed to scipy.optimize.minimize

    Returns either:
        (a) the minimizing argument of a one-argument function
        (b) an array of minimizing arguments of a multi-argument function