sqrtm — SciPy v1.15.2 Manual (original) (raw)
scipy.linalg.
scipy.linalg.sqrtm(A, disp=True, blocksize=64)[source]#
Matrix square root.
Parameters:
A(N, N) array_like
Matrix whose square root to evaluate
dispbool, optional
Print warning if error in the result is estimated large instead of returning estimated error. (Default: True)
blocksizeinteger, optional
If the blocksize is not degenerate with respect to the size of the input array, then use a blocked algorithm. (Default: 64)
Returns:
sqrtm(N, N) ndarray
Value of the sqrt function at A. The dtype is float or complex. The precision (data size) is determined based on the precision of input A.
errestfloat
(if disp == False)
Frobenius norm of the estimated error, ||err||_F / ||A||_F
References
[1]
Edvin Deadman, Nicholas J. Higham, Rui Ralha (2013) “Blocked Schur Algorithms for Computing the Matrix Square Root, Lecture Notes in Computer Science, 7782. pp. 171-182.
Examples
import numpy as np from scipy.linalg import sqrtm a = np.array([[1.0, 3.0], [1.0, 4.0]]) r = sqrtm(a) r array([[ 0.75592895, 1.13389342], [ 0.37796447, 1.88982237]]) r.dot(r) array([[ 1., 3.], [ 1., 4.]])