real_gen_matrix_sqrt computes the principal matrix square root, , of a real matrix .

For full information please refer to the NAG Library document for f01en

afloat, array-like, shape

The matrix .

afloat, ndarray, shape

Contains, if no exception or warning is raised, the principal matrix square root, . Alternatively, if = 1, contains an non-principal square root of .

(errno )

On entry, .

Constraint: .

(errno )

has a defective vanishing eigenvalue. The square root cannot be found in this case.

(errno )

has a negative real eigenvalue. The principal square root is not defined. complex_gen_matrix_sqrt() can be used to return a complex, non-principal square root.

(errno )

An internal error occurred. It is likely that the function was called incorrectly.

(errno )

has a semisimple vanishing eigenvalue. A non-principal square root is returned.


A square root of a matrix is a solution to the equation . A nonsingular matrix has multiple square roots. For a matrix with no eigenvalues on the closed negative real line, the principal square root, denoted by , is the unique square root whose eigenvalues lie in the open right half-plane.

is computed using the algorithm described in Higham (1987). This is a real arithmetic version of the algorithm of Björck and Hammarling (1983). In addition a blocking scheme described in Deadman et al. (2013) is used.


Björck, Å and Hammarling, S, 1983, A Schur method for the square root of a matrix, Linear Algebra Appl. (52/53), 127–140

Deadman, E, Higham, N J and Ralha, R, 2013, Blocked Schur Algorithms for Computing the Matrix Square Root, Applied Parallel and Scientific Computing: 11th International Conference, (PARA 2012, Helsinki, Finland), P. Manninen and P. Öster, Eds, Lecture Notes in Computer Science (7782), 171–181, Springer–Verlag

Higham, N J, 1987, Computing real square roots of a real matrix, Linear Algebra Appl. (88/89), 405–430

Higham, N J, 2008, Functions of Matrices: Theory and Computation, SIAM, Philadelphia, PA, USA