# [SciPy-Dev] Strange behaviour of gmres

Nils Wagner nwagner@iam.uni-stuttgart...
Mon Jun 20 15:04:19 CDT 2011

```Hi all,

who can shed light on the following behaviour of gmres ?

Nils

import numpy as np
import scipy.sparse.linalg

for n in range(2,25):
A = np.random.rand(n, n) + 1j*np.random.rand(n, n)
b = np.random.rand(n) + 1j*np.random.rand(n)
x, info = scipy.sparse.linalg.gmres(A, b)
y = np.linalg.solve(A, b)
print 'order of the matrix %i info: %i error %e '
%(n, info, abs(x - y).max())

order of the matrix 2 info: 0 error 2.482534e-16
order of the matrix 3 info: 0 error 3.723801e-16
order of the matrix 4 info: 0 error 1.680072e-15
order of the matrix 5 info: 0 error 4.965068e-15
order of the matrix 6 info: 0 error 2.909013e-16
order of the matrix 7 info: 0 error 4.820209e-15
order of the matrix 8 info: 0 error 1.012318e-15
order of the matrix 9 info: 0 error 1.404333e-15
order of the matrix 10 info: 0 error 1.807312e-15
order of the matrix 11 info: 0 error 4.428663e-14
order of the matrix 12 info: 0 error 7.304728e-15
order of the matrix 13 info: 0 error 2.100054e-14
order of the matrix 14 info: 0 error 3.038038e-14
order of the matrix 15 info: 0 error 1.333712e-15
order of the matrix 16 info: 0 error 9.711044e-14
order of the matrix 17 info: 0 error 1.405430e-15
order of the matrix 18 info: 0 error 1.519019e-14
order of the matrix 19 info: 0 error 7.759657e-15
order of the matrix 20 info: 0 error 6.402436e-14
order of the matrix 21 info: 0 error 1.273827e-04
order of the matrix 22 info: 220 error 4.131225e-02
order of the matrix 23 info: 230 error 1.475908e+00
order of the matrix 24 info: 240 error 1.899145e+00
```