title: Gauss Siedel not converging
body: <p>I have written this code, which is not converging and runs more iterations than I expect. I expect it to run 17 iterations and it does 24. I am not able to figure out the reason!</p>
  <pre><code>import numpy as np
  from numpy import *
  
  A = [[10, -1, 2, 0],
      [ -1, 11, -1, 3 ], 
      [ 2, -1, 10, -1 ],
      [ 0, 3, -1, 8 ] ]
  b = [6, 25, -11, 15]
  
  def GaussSiedelAccelerated(A, b, e, x, w):
    
      e = float(e)
      iterations = 0
      Epsilon = float()
      
      n = len(A)
      condition = True
      
      while condition:
          for i in range(n):
              s1 = 0
              s2 = 0 
              tempx = x.copy() # Record answer of the previous iteration
              for j in range(1,i,1):
                      s1 = s1 + x[j]*A[i][j]
              for k in range(i+1,n,1):
                      s2 = s2 + tempx[k]*A[i][k]
              x[i] = x[i]*(1-w) + w*(b[i] - s1 - s2)/A[i][i]
              
              iterations = iterations +1
              Epsilon = max(abs(x-tempx))/max(abs(x))
              print(&quot;Output vector for the run no.&quot;, iterations, &quot;is:&quot;, x)
              print(&quot;Error for the run no.&quot;, iterations, &quot;is:     \t&quot;, Epsilon)
              
              condition = Epsilon &gt; e
              
      return x, Epsilon, iterations
  
  x0 = np.zeros(len(A))
  x, Epsilon, iterations = GaussSiedelAccelerated(A,b,0.0001,x0, 1.1)
  </code></pre>