<h3 dir="auto">Describe your issue.</h3>
<p dir="auto">When the <code class="notranslate">hybr</code> method doesn't converge, it may sometimes report erroneously <code class="notranslate">success = True</code>. For example, looking at the function <math-renderer class="js-inline-math" style="display: inline" data-static-url="https://github.githubassets.com/static" data-run-id="4bb54094887c3081cfb9a4e58bed962d">$f(x) = x^2-2x$</math-renderer> for initial value <math-renderer class="js-inline-math" style="display: inline" data-static-url="https://github.githubassets.com/static" data-run-id="4bb54094887c3081cfb9a4e58bed962d">$x_0=1$</math-renderer> (or values very close to <math-renderer class="js-inline-math" style="display: inline" data-static-url="https://github.githubassets.com/static" data-run-id="4bb54094887c3081cfb9a4e58bed962d">$1$</math-renderer>), this method reports convergence on <code class="notranslate">1.01</code> .</p>
<p dir="auto">When looking at other methods available in <code class="notranslate">root</code>, <code class="notranslate">hybr</code> is the only one to falsely report success while being clearly not converged.</p>
<p dir="auto">I would propose adding a last function call to <code class="notranslate">hybr</code> and setting <code class="notranslate">success</code> accordingly</p>
<h3 dir="auto">Reproducing Code Example</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; root(lambda x: x**2-2*x, x0=1.)
    fjac: array([[-1.]])
     fun: array([-0.9999])
 message: 'The solution converged.'
    nfev: 6
     qtf: array([0.9999])
       r: array([-0.02000001])
  status: 1
 success: True
       x: array([1.01])

&gt;&gt;&gt; methods = ['hybr', 'lm', 'broyden1', 'broyden2',
... 'anderson', 'linearmixing', 'diagbroyden', 'excitingmixing',
... 'krylov', 'df-sane']
&gt;&gt;&gt; for m in methods:
...     r = root(lambda x: x**2-2*x, x0=1., method=m)
...     print(f&quot;{m}: {r.success = }, {r.x = }&quot;)
... 
hybr: r.success = True, r.x = array([1.01])
lm: r.success = True, r.x = array([2.])
broyden1: r.success = True, r.x = array(4.46196389e-07)
broyden2: r.success = True, r.x = array(4.46196389e-07)
anderson: r.success = True, r.x = array(1.4289777e-06)
linearmixing: r.success = True, r.x = array(4.65661287e-10)
diagbroyden: r.success = True, r.x = array(4.46196389e-07)
excitingmixing: r.success = True, r.x = array(1.18976516e-07)
krylov: r.success = False, r.x = array(1.)
df-sane: r.success = True, r.x = array(2.)"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-en">root</span>(<span class="pl-k">lambda</span> <span class="pl-s1">x</span>: <span class="pl-s1">x</span><span class="pl-c1">**</span><span class="pl-c1">2</span><span class="pl-c1">-</span><span class="pl-c1">2</span><span class="pl-c1">*</span><span class="pl-s1">x</span>, <span class="pl-s1">x0</span><span class="pl-c1">=</span><span class="pl-c1">1.</span>)
    <span class="pl-s1">fjac</span>: <span class="pl-en">array</span>([[<span class="pl-c1">-</span><span class="pl-c1">1.</span>]])
     <span class="pl-s1">fun</span>: <span class="pl-en">array</span>([<span class="pl-c1">-</span><span class="pl-c1">0.9999</span>])
 <span class="pl-s1">message</span>: <span class="pl-s">'The solution converged.'</span>
    <span class="pl-s1">nfev</span>: <span class="pl-c1">6</span>
     <span class="pl-s1">qtf</span>: <span class="pl-en">array</span>([<span class="pl-c1">0.9999</span>])
       <span class="pl-s1">r</span>: <span class="pl-en">array</span>([<span class="pl-c1">-</span><span class="pl-c1">0.02000001</span>])
  <span class="pl-s1">status</span>: <span class="pl-c1">1</span>
 <span class="pl-s1">success</span>: <span class="pl-c1">True</span>
       <span class="pl-s1">x</span>: <span class="pl-en">array</span>([<span class="pl-c1">1.01</span>])

<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">methods</span> <span class="pl-c1">=</span> [<span class="pl-s">'hybr'</span>, <span class="pl-s">'lm'</span>, <span class="pl-s">'broyden1'</span>, <span class="pl-s">'broyden2'</span>,
... <span class="pl-s">'anderson'</span>, <span class="pl-s">'linearmixing'</span>, <span class="pl-s">'diagbroyden'</span>, <span class="pl-s">'excitingmixing'</span>,
... <span class="pl-s">'krylov'</span>, <span class="pl-s">'df-sane'</span>]
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">for</span> <span class="pl-s1">m</span> <span class="pl-c1">in</span> <span class="pl-s1">methods</span>:
...     <span class="pl-s1">r</span> <span class="pl-c1">=</span> <span class="pl-en">root</span>(<span class="pl-k">lambda</span> <span class="pl-s1">x</span>: <span class="pl-s1">x</span><span class="pl-c1">**</span><span class="pl-c1">2</span><span class="pl-c1">-</span><span class="pl-c1">2</span><span class="pl-c1">*</span><span class="pl-s1">x</span>, <span class="pl-s1">x0</span><span class="pl-c1">=</span><span class="pl-c1">1.</span>, <span class="pl-s1">method</span><span class="pl-c1">=</span><span class="pl-s1">m</span>)
...     <span class="pl-s1">print</span>(<span class="pl-s">f"<span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">m</span><span class="pl-kos">}</span></span>: <span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">r</span>.<span class="pl-s1">success</span> <span class="pl-c1">=</span> <span class="pl-kos">}</span></span>, <span class="pl-s1"><span class="pl-kos">{</span><span class="pl-s1">r</span>.<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-kos">}</span></span>"</span>)
... 
<span class="pl-s1">hybr</span>: <span class="pl-s1">r</span>.<span class="pl-s1">success</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span>, <span class="pl-s1">r</span>.<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-en">array</span>([<span class="pl-c1">1.01</span>])
<span class="pl-s1">lm</span>: <span class="pl-s1">r</span>.<span class="pl-s1">success</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span>, <span class="pl-s1">r</span>.<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-en">array</span>([<span class="pl-c1">2.</span>])
<span class="pl-s1">broyden1</span>: <span class="pl-s1">r</span>.<span class="pl-s1">success</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span>, <span class="pl-s1">r</span>.<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-en">array</span>(<span class="pl-c1">4.46196389e-07</span>)
<span class="pl-s1">broyden2</span>: <span class="pl-s1">r</span>.<span class="pl-s1">success</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span>, <span class="pl-s1">r</span>.<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-en">array</span>(<span class="pl-c1">4.46196389e-07</span>)
<span class="pl-s1">anderson</span>: <span class="pl-s1">r</span>.<span class="pl-s1">success</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span>, <span class="pl-s1">r</span>.<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-en">array</span>(<span class="pl-c1">1.4289777e-06</span>)
<span class="pl-s1">linearmixing</span>: <span class="pl-s1">r</span>.<span class="pl-s1">success</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span>, <span class="pl-s1">r</span>.<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-en">array</span>(<span class="pl-c1">4.65661287e-10</span>)
<span class="pl-s1">diagbroyden</span>: <span class="pl-s1">r</span>.<span class="pl-s1">success</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span>, <span class="pl-s1">r</span>.<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-en">array</span>(<span class="pl-c1">4.46196389e-07</span>)
<span class="pl-s1">excitingmixing</span>: <span class="pl-s1">r</span>.<span class="pl-s1">success</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span>, <span class="pl-s1">r</span>.<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-en">array</span>(<span class="pl-c1">1.18976516e-07</span>)
<span class="pl-s1">krylov</span>: <span class="pl-s1">r</span>.<span class="pl-s1">success</span> <span class="pl-c1">=</span> <span class="pl-c1">False</span>, <span class="pl-s1">r</span>.<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-en">array</span>(<span class="pl-c1">1.</span>)
<span class="pl-s1">df</span><span class="pl-c1">-</span><span class="pl-s1">sane</span>: <span class="pl-s1">r</span>.<span class="pl-s1">success</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span>, <span class="pl-s1">r</span>.<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-en">array</span>(<span class="pl-c1">2.</span>)</pre></div>
<h3 dir="auto">Error message</h3>
<div class="highlight highlight-source-shell notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="-"><pre class="notranslate">-</pre></div>
<h3 dir="auto">SciPy/NumPy/Python version information</h3>
<p dir="auto">1.9.3 1.23.4 sys.version_info(major=3, minor=10, micro=6, releaselevel='final', serial=0)</p>
<p dir="auto">Running</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from scipy.optimize import root
print(root(lambda x: (x - 1) ** 2 - 1, 1))
print(root(lambda x: (x - 1.6667898)**2 - 2, 1.66678977))"><pre class="notranslate"><code class="notranslate">from scipy.optimize import root
print(root(lambda x: (x - 1) ** 2 - 1, 1))
print(root(lambda x: (x - 1.6667898)**2 - 2, 1.66678977))
</code></pre></div>
<p dir="auto">gives the ridiculous results</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    fjac: array([[-1.]])
     fun: array([-0.9999])
 message: 'The solution converged.'
    nfev: 6
     qtf: array([ 0.9999])
       r: array([-0.02000001])
  status: 1
 success: True
       x: array([ 1.01])"><pre class="notranslate"><code class="notranslate">    fjac: array([[-1.]])
     fun: array([-0.9999])
 message: 'The solution converged.'
    nfev: 6
     qtf: array([ 0.9999])
       r: array([-0.02000001])
  status: 1
 success: True
       x: array([ 1.01])
</code></pre></div>
<p dir="auto">and</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    fjac: array([[-1.]])
     fun: array([-1.99985602])
 message: 'The solution converged.'
    nfev: 6
     qtf: array([ 1.99985602])
       r: array([ 0.02399826])
  status: 1
 success: True
       x: array([ 1.65479065])"><pre class="notranslate"><code class="notranslate">    fjac: array([[-1.]])
     fun: array([-1.99985602])
 message: 'The solution converged.'
    nfev: 6
     qtf: array([ 1.99985602])
       r: array([ 0.02399826])
  status: 1
 success: True
       x: array([ 1.65479065])
</code></pre></div>
<p dir="auto">These should not happen.</p>
<h3 dir="auto">Scipy/Numpy/Python version information:</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="0.19.0, 1.12.1, version_info(major=2, minor=7, micro=13, releaselevel='final', serial=0)"><pre class="notranslate"><code class="notranslate">0.19.0, 1.12.1, version_info(major=2, minor=7, micro=13, releaselevel='final', serial=0)
</code></pre></div>