<p dir="auto">When any one of the independent variables are bound to a single number (by setting the upper bound equal to the lower bound), the SLSQP optimization fails. However, setting the bounds to (lower_bound, upper_bound + 1e-8) works fine. This wasn't an issue in 1.4.1 and seems to have started happening in 1.5.0.</p>
<h4 dir="auto">Reproducing code example:</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import scipy.optimize as opt
import numpy as np


def f(x: np.ndarray):
    return 0.4 * x[0]**2 + 0.6 * x[0] * x[1] + 0.85 * x[1]**2 - 5 * x[1]


x0 = np.array([0, 0])
bounds = [(0, 0), (-np.inf, np.inf)]
output1 = opt.minimize(f, x0, method='SLSQP', bounds=bounds)

bounds = [(0, 1e-8), (-np.inf, np.inf)]
output2 = opt.minimize(f, x0, method='SLSQP', bounds=bounds)

print(output1)
print(output2)"><pre class="notranslate"><code class="notranslate">import scipy.optimize as opt
import numpy as np


def f(x: np.ndarray):
    return 0.4 * x[0]**2 + 0.6 * x[0] * x[1] + 0.85 * x[1]**2 - 5 * x[1]


x0 = np.array([0, 0])
bounds = [(0, 0), (-np.inf, np.inf)]
output1 = opt.minimize(f, x0, method='SLSQP', bounds=bounds)

bounds = [(0, 1e-8), (-np.inf, np.inf)]
output2 = opt.minimize(f, x0, method='SLSQP', bounds=bounds)

print(output1)
print(output2)
</code></pre></div>
<h4 dir="auto">Results:</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="  J_transposed[i] = df / dx
     fun: 0.0
     jac: array([        nan, -4.99999999])
 message: 'Inequality constraints incompatible'
    nfev: 3
     nit: 1
    njev: 1
  status: 4
 success: False
       x: array([0., 0.])

     fun: -7.352941176470589
     jac: array([1.76470589, 0.        ])
 message: 'Optimization terminated successfully'
    nfev: 9
     nit: 3
    njev: 3
  status: 0
 success: True
       x: array([0.        , 2.94117646])"><pre class="notranslate"><code class="notranslate">  J_transposed[i] = df / dx
     fun: 0.0
     jac: array([        nan, -4.99999999])
 message: 'Inequality constraints incompatible'
    nfev: 3
     nit: 1
    njev: 1
  status: 4
 success: False
       x: array([0., 0.])

     fun: -7.352941176470589
     jac: array([1.76470589, 0.        ])
 message: 'Optimization terminated successfully'
    nfev: 9
     nit: 3
    njev: 3
  status: 0
 success: True
       x: array([0.        , 2.94117646])
</code></pre></div>
<h4 dir="auto">Scipy/Numpy/Python version information:</h4>
<p dir="auto">1.5.0 1.19.1 sys.version_info(major=3, minor=8, micro=5, releaselevel='final', serial=0)</p>
<p dir="auto">Hello,</p>
<p dir="auto">It seems that in _numdiff.py module the _dense_difference function does not take into account situation of an optimisation with equal bounds constraints and where initial solution respect this constraint for some .</p>
<p dir="auto">In that case line 519 in _numdiff.py module dx and df are equal to zero and trigger nan in the jacobian.</p>
<p dir="auto">It then triggers an exit n° 4 "Inequality constraints incompatible"</p>
<h4 dir="auto">Scipy/Numpy/Python version information:</h4>
<p dir="auto">1.5.1 1.16.5 sys.version_info(major=3, minor=7, micro=4, releaselevel='final', serial=0)</p>
<p dir="auto">my script does not raise error with following setup</p>
<p dir="auto">1.3.1 1.16.5 sys.version_info(major=3, minor=7, micro=4, releaselevel='final', serial=0)</p>