Jacobian and Hessian inputs in `scipy.optimize.minimize`
<p>I am trying to understand how the "dogleg" method works in Python's <a href="https://docs.scipy.org/doc/scipy-0.18.1/reference/generated/scipy.optimize.minimize.html" rel="noreferrer"><code>scipy.optimize.minimize</code></a> function. I am adapting the example at the bottom of the help page.</p>

<p>The dogleg method requires a Jacobian and Hessian argument according to the notes. For this I use the <a href="https://media.readthedocs.org/pdf/numdifftools/latest/numdifftools.pdf" rel="noreferrer"><code>numdifftools</code></a> package:</p>

<pre><code>import numpy as np
from scipy.optimize import minimize
from numdifftools import Jacobian, Hessian

def fun(x,a):
    return (x[0] - 1)**2 + (x[1] - a)**2

x0 = np.array([2,0]) # initial guess
a = 2.5

res = minimize(fun, x0, args=(a), method='dogleg',
               jac=Jacobian(fun)([2,0]), hess=Hessian(fun)([2,0]))

print(res)
</code></pre>

<p><strong>Edit:</strong></p>

<p>If I make a change as suggested by a post below,</p>

<pre><code>res = minimize(fun, x0, args=a, method='dogleg',
               jac=Jacobian(lambda x: fun(x,a)),
               hess=Hessian(lambda x: fun(x,a)))
</code></pre>

<p>I get an error <code>TypeError: &lt;lambda&gt;() takes 1 positional argument but 2 were given</code>. What am I doing wrong?</p>

<p>Also is it correct to calculate the Jacobian and Hessian at the initial guess <code>x0</code>?</p>