code: private void improve(ColumnVector b, ColumnVector x)
          throws MatrixException
      {
          // Find the largest x element.
          double largestX = 0;
          for (int r = 0; r < nRows; ++r) {
              double absX = Math.abs(x.values[r][0]);
              if (largestX < absX) largestX = absX;
          }
  
          // Is x already as good as possible?
          if (largestX == 0) return;
  
          ColumnVector residuals = new ColumnVector(nRows);
  
          // Iterate to improve x.
          for (int iter = 0; iter < MAX_ITER; ++iter) {
  
              // Compute residuals = b - Ax.
              // Must use double precision!
              for (int r = 0; r < nRows; ++r) {
                  double dot   = 0;
                  double  row[] = values[r];
                  for (int c = 0; c < nRows; ++c) {
                      double elmt = at(r, c);
                      dot += elmt*x.at(c);        // dbl.prec. *
                  }
                  double value = b.at(r) - dot;   // dbl.prec. -
                  residuals.set(r, (double) value);
              }
  
              // Solve Az = residuals for z.
              ColumnVector z = solve(residuals, false);
  
              // Set x = x + z.
              // Find largest the largest difference.
              double largestDiff = 0;
              for (int r = 0; r < nRows; ++r) {
                  double oldX = x.at(r);
                  x.set(r, oldX + z.at(r));
  
                  double diff = Math.abs(x.at(r) - oldX);
                  if (largestDiff < diff) largestDiff = diff;
              }
  
              // Is any further improvement possible?
              if (largestDiff < largestX*TOLERANCE) return;
          }
  
          // Failed to converge because A is nearly singular.
          throw new MatrixException(MatrixException.NO_CONVERGENCE);
      }
docs: Iteratively improve the solution x to machine accuracy.
  @param b the right-hand side column vector
  @param x the improved solution column vector
  @throws matrix.MatrixException if failed to converge