| MATLAB Function Reference | ![]() |
Syntax
X = sqrtm(A) [X,resnorm] = sqrtm(A) [X,alpha,condest] = sqrtm(A)
Description
X = sqrtm(A)
把矩陣 A 開平方根, X*X = A.
當每個特徵值(eignvalues)的實數部分不是負數,X 為單一平方根。若 A
有特徵值的實數部分為負數,則會產生複數的結果(complex result) 。如果 A 是單一矩陣(singular)則不會有任何平方根。若偵測到單一矩陣的形式則會顯示出警告訊息。
[X, resnorm] = sqrtm(A)
不會顯示任何警告訊息,而會回傳餘數(residual), norm(A-X^2,'fro')/norm(A,'fro').
[X, alpha, condest] = sqrtm(A)
回傳穩定要素(stability factor) alpha 和矩陣 X
的平方根條件數(condition number)的估計值 condest。 而餘數(residual) norm(A-X^2,'fro')/norm(A,'fro')
逼近(is bounded approximately by) n*alpha*eps 而且 Frobenius norm relative error in X
逼近(is bounded approximately by) n*alpha*condest*eps,而 n = max(size(A)).
Remarks
若 X 是都是實數、對稱而且???(positive definite)或者是複數、??Hermitian
而且正定(positive definite),則計算出來的平方根也是如此。
某些矩陣沒有平方根、實數或複數,例如 X = [0 1; 0 0],則 sqrtm
無法計算出結果???(cannot be expected to produce one.)
Examples
Example 1. A matrix representation of the fourth difference operator is
X =
5 -4 1 0 0
-4 6 -4 1 0
1 -4 6 -4 1
0 1 -4 6 -4
0 0 1 -4 5
此矩陣是對稱且定正( positive definite)。所以他也有單一且 定正(positive definite) 的平方根 Y = sqrtm(X), is a representation of the second difference operator.
Y =
2 -1 -0 -0 -0
-1 2 -1 0 -0
0 -1 2 -1 0
-0 0 -1 2 -1
-0 -0 -0 -1 2
X =
7 10
15 22
Y1 =
1.5667 1.7408
2.6112 4.1779
Y2 =
1 2
3 4
另外二個為 -Y1 和 -Y2。這四個都可以從 X
的特徵值和特徵向量來求得
[V,D] = eig(X);
D =
0.1386 0
0 28.8614
對角矩陣 D 的四個平方根為下列矩陣中四種可能的正負號組合所產生的四個矩陣
S =
±0.3723 0
0 ±5.3723
Y = V*S/V
即使 Y2 的元素都是正整數, sqrtm
還是選擇二個正號而產生 Y1。
See Also
expm 矩陣的指數運算(Matrix exponential)
funm 計算矩陣的函式(Evaluate functions of a matrix)
logm 矩陣的對數運算(Matrix logarithm)
| sqrt | squeeze | ![]() |