BUG: sparse.linalg.minres: residual increases when given more iterations for low rtol values
Author: ReallyCoolNameCreated Jan 9, 2026Updated Sep 18, 2026
Labelsdefectscipy.sparse.linalg
Describe your issue.
The residual for
res1 = sparse.linalg.minres(Amat,bvec,rtol=1e-14,check=True,maxiter=1000)
is larger than the residual from
res2 = sparse.linalg.minres(Amat,bvec,rtol=1e-14,check=True,maxiter=4000)
(by over 4 orders of magnitude)
However for rtol=1e-10 there is no problem.
The data (and the python script to test it) are available here (I'd have posted a small example, but I couldn't reproduce the problem for a reasonably small matrix I could post here)
Reproducing Code Example
import numpy as np
from scipy import sparse
Amat = np.load("Amat.npy")
bvec = np.load("bvec.npy")
Amat = sparse.csr_array(Amat)
res1 = sparse.linalg.minres(Amat,bvec,rtol=1e-14,check=True,maxiter=1000)
res2 = sparse.linalg.minres(Amat,bvec,rtol=1e-14,check=True,maxiter=4000)
print(f"Exit reason for 1000 iteration test: {res1[1]}\nExit reason for 4000 iteration test: {res2[1]}")
print(f"Residual for 1000 iteration test: {np.linalg.norm((Amat @ res1[0][:,np.newaxis])-bvec)}\nResidual for 4000 iteration test: {np.linalg.norm((Amat @ res2[0][:,np.newaxis])-bvec)}")Error message
No errors.SciPy/NumPy/Python version and system information
1.16.3 1.26.4 sys.version_info(major=3, minor=12, micro=4, releaselevel='final', serial=0)
Build Dependencies:
blas:
detection method: pkgconfig
found: true
include directory: C:/Users/runneradmin/AppData/Local/Temp/cibw-run-0_as6mvx/cp312-win_amd64/build/venv/Lib/site-packages/scipy_openblas32/include
lib directory: C:/Users/runneradmin/AppData/Local/Temp/cibw-run-0_as6mvx/cp312-win_amd64/build/venv/Lib/site-packages/scipy_openblas32/lib
name: scipy-openblas
openblas configuration: OpenBLAS 0.3.29.dev DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=24
pc file directory: D:/a/scipy/scipy
version: 0.3.29.dev
lapack:
detection method: pkgconfig
found: true
include directory: C:/Users/runneradmin/AppData/Local/Temp/cibw-run-0_as6mvx/cp312-win_amd64/build/venv/Lib/site-packages/scipy_openblas32/include
lib directory: C:/Users/runneradmin/AppData/Local/Temp/cibw-run-0_as6mvx/cp312-win_amd64/build/venv/Lib/site-packages/scipy_openblas32/lib
name: scipy-openblas
openblas configuration: OpenBLAS 0.3.29.dev DYNAMIC_ARCH NO_AFFINITY Haswell MAX_THREADS=24
pc file directory: D:/a/scipy/scipy
version: 0.3.29.dev
pybind11:
detection method: config-tool
include directory: unknown
name: pybind11
version: 3.0.1
Compilers:
c:
commands: cc
linker: ld.bfd
name: gcc
version: 10.3.0
c++:
commands: c++
linker: ld.bfd
name: gcc
version: 10.3.0
cython:
commands: cython
linker: cython
name: cython
version: 3.1.6
fortran:
commands: gfortran
linker: ld.bfd
name: gcc
version: 10.3.0
pythran:
include directory: C:\Users\runneradmin\AppData\Local\Temp\build-env-dfcay8wl\Lib\site-packages/pythran
version: 0.18.0
Machine Information:
build:
cpu: x86_64
endian: little
family: x86_64
system: windows
cross-compiled: false
host:
cpu: x86_64
endian: little
family: x86_64
system: windows
Python Information:
path: C:\Users\runneradmin\AppData\Local\Temp\build-env-dfcay8wl\Scripts\python.exe
version: '3.12'Source: scipy/scipy