# Buggy code
def _minimize_trustregion_exact(
    fun, x0, args=(), jac=None, hess=None, **trust_region_options
):
    """
    Minimization of scalar function of one or more variables using
    a nearly exact trust-region algorithm.

    Options
    -------
    initial_tr_radius : float
        Initial trust-region radius.
    max_tr_radius : float
        Maximum value of the trust-region radius. No steps that are longer
        than this value will be proposed.
    eta : float
        Trust region related acceptance stringency for proposed steps.
    gtol : float
        Gradient norm must be less than ``gtol`` before successful
        termination.
    """

    if jac is None:
        raise ValueError(
            "Jacobian is required for trust region ", "exact minimization."
        )
    if hess is None:
        raise ValueError(
            "Jacobian is required for trust region ", "exact minimization."
        )
    return _minimize_trust_region(
        fun,
        x0,
        args=args,
        jac=jac,
        hess=hess,
        subproblem=IterativeSubproblem,
        **trust_region_options,
    )


# Traceback (ValueError)
In [11]: import numpy as np

In [12]: from scipy.optimize import minimize

In [13]: minimize(lambda x: np.dot(x, x), [1, 1], jac=lambda x: 2*x, method='trust-exact')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-13-48bed8d3f104> in <module>()
----> 1 minimize(lambda x: np.dot(x, x), [1, 1], jac=lambda x: 2*x, method='trust-exact')

/Users/warren/miniconda3scipy/lib/python3.5/site-packages/scipy-1.0.0.dev0+bad9919-py3.5-macosx-10.6-x86_64.egg/scipy/optimize/_minimize.py in minimize(fun, x0, args, method, jac, hess, hessp, bounds, constraints, tol, callback, options)
480     elif meth == 'trust-exact':
481         return _minimize_trustregion_exact(fun, x0, args, jac, hess,
--> 482                                            callback=callback, **options)
483     else:
484         raise ValueError('Unknown solver %s' % method)

/Users/warren/miniconda3scipy/lib/python3.5/site-packages/scipy-1.0.0.dev0+bad9919-py3.5-macosx-10.6-x86_64.egg/scipy/optimize/_trustregion_exact.py in _minimize_trustregion_exact(fun, x0, args, jac, hess, **trust_region_options)
38     if hess is None:
39         raise ValueError('Jacobian is required for trust region ',
---> 40                          'exact minimization.')
41     return _minimize_trust_region(fun, x0, args=args, jac=jac, hess=hess,
42                                   subproblem=IterativeSubproblem,

ValueError: ('Jacobian is required for trust region ', 'exact minimization.')

# Fixed code
def _minimize_trustregion_exact(
    fun, x0, args=(), jac=None, hess=None, **trust_region_options
):
    """
    Minimization of scalar function of one or more variables using
    a nearly exact trust-region algorithm.

    Options
    -------
    initial_tr_radius : float
        Initial trust-region radius.
    max_tr_radius : float
        Maximum value of the trust-region radius. No steps that are longer
        than this value will be proposed.
    eta : float
        Trust region related acceptance stringency for proposed steps.
    gtol : float
        Gradient norm must be less than ``gtol`` before successful
        termination.
    """

    if jac is None:
        raise ValueError("Jacobian is required for trust region exact minimization.")
    if hess is None:
        raise ValueError(
            "Hessian matrix is required for trust region exact minimization."
        )
    return _minimize_trust_region(
        fun,
        x0,
        args=args,
        jac=jac,
        hess=hess,
        subproblem=IterativeSubproblem,
        **trust_region_options,
    )