function Y = matrix_sign(X) % Y = MATRIX_SIGN(X) computes the matrix sign function by means of the % scaled Newton's method % X: a square matrix % Y: the sign of X n = size (X,1); tol = 1e-13; kmax = 20; err = 1; Y = X; k = 0; while err>tol && k