Python, scipy : minimize multivariable function in integral expression
Question: 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):

    
    
    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))
    

i tried:

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

but I get errors. I get the results in matlab.

any idea ?

thanks in advance


Answer: 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 [minimal, complete and
verifiable example](http://stackoverflow.com/help/mcve) that we can run to
reproduce the problem. Currently, you define `function`, but later you use the
undefined function `chirplet`. That makes it a little bit harder for anyone to
understand your problem.

Having said that...

[`scipy.integrate.quad`](http://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.quad.html)
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 `function`. Try something like this:

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

