If matrix is singular returns nil, else returns the inverse of matrix. Uses iterative improvement until no further improvement is possible.