Python, scipy : minimize multivariable function in integral expression
<p>how can I minimize a function (uncostrained), respect a[0] and a[1]?
example (this is a simple example for I uderstand scipy, numpy and py):</p>

<pre><code>import numpy as np
from scipy.integrate import *
from scipy.optimize import *
def function(a):
    return(quad(lambda t: ((np.cos(a[0]))*(np.sin(a[1]))*t),0,3))
</code></pre>

<p>i tried:</p>

<pre><code>l=np.array([0.1,0.2])
res=minimize(function,l, method='nelder-mead',options={'xtol': 1e-8, 'disp':    True})
</code></pre>

<p>but I get errors.
I get the results in matlab.</p>

<p>any idea ?</p>

<p>thanks in advance</p>

<p>This is just a guess, because you haven't included enough information in the question for anyone to really know what the problem is.  Whenever you ask a question about code that generates an error, always include the complete error message in the question.  Ideally, you should include a <a href="http://stackoverflow.com/help/mcve">minimal, complete and verifiable example</a> that we can run to reproduce the problem.   Currently, you define <code>function</code>, but later you use the undefined function <code>chirplet</code>.  That makes it a little bit harder for anyone to understand your problem.</p>

<p>Having said that...</p>

<p><a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.quad.html" rel="nofollow"><code>scipy.integrate.quad</code></a> returns two values: the estimate of the integral, and an estimate of the absolute error of the integral.  It looks like you haven't taken this into account in <code>function</code>.   Try something like this:</p>

<pre><code>def function(a):
    intgrl, abserr = quad(lambda t: np.cos(a[0])*np.sin(a[1])*t, 0, 3)
    return intgrl
</code></pre>

python numpy optimization scipy