title: Functional Constrained Optimization Python Incorrect Answer
body: <p>I'm trying to minimize a functional (integral of a function), given constraints</p>
  
  <pre><code>def s(y,a,b,c,d):
      v = [1, y, y**2, y**3]
      alpha = [a, b, c, d]
      q = np.inner(v,alpha)
      return -q*np.exp(-q)
  def p(y,a,b,c,d):
      v = [1, y, y**2, y**3]
      alpha = [a, b, c, d]
      q = np.inner(v,alpha)
      return np.exp(-q)
  
  def Q(u):
      a, b, c, d = u
      d = integrate.quad(lambda y: s(y,a,b,c,d), 0, 1)
      return d[0]
  cons = ({'type': 'eq', 'fun' : integrate.quad(lambda y: p(y,a,b,c,d), 0,     1)[0]-1},
      {'type': 'eq', 'fun' : integrate.quad(lambda y: (p(y,a,b,c,d)*y), 0, 1)[0]-0.483523521402009},
      {'type': 'eq', 'fun' : integrate.quad(lambda y: (p(y,a,b,c,d)*y**2), 0, 1)[0]-0.300458990347083},
      {'type': 'eq', 'fun' : integrate.quad(lambda y: (p(y,a,b,c,d)*y**3), 0, 1)[0]-0.209996591802522})
  res = minimize(Q, x0 = (0, 0, 0, 0), method='BFGS', constraints=cons)
  print(res)
  </code></pre>
  
  <p>I get an output</p>
  
  <pre><code>fun: -0.36787942624169967
   hess_inv: array([[  17.98311921,  -49.74794121,    2.50822967,   36.21942131],
     [ -49.74794121,  191.70720321,  -23.14586623, -158.65310285],
     [   2.50822967,  -23.14586623,    8.1640543 ,   25.72129091],
     [  36.21942131, -158.65310285,   25.72129091,  142.59127393]])
    jac: array([ -3.54647636e-06,  -1.94460154e-06,  -1.75461173e-06,
       3.24100256e-07])
    message: 'Optimization terminated successfully.'
   nfev: 126*
    *nit: 19
   njev: 21
     status: 0
    success: True
      x: array([ 0.99920744,  0.0092224 , -0.02276881,  0.0150456 ])**
  </code></pre>
  
  <p>However using this array of X, does not satisfy the constraint</p>
  
  <pre><code>x = (0.99920744,  0.0092224 , -0.02276881,  0.0150456)
  integrate.quad(lambda y: p(y,x[0],x[1],x[2],x[3]), 0, 1)[0]
  </code></pre>
  
  <p>0.3678829742546207 </p>
  
  <p>which is not 1, as specifically stated in the constraint. How is it claiming convergence when it clearly has not converged?</p>