# How to calculate all the square roots of a matrix?

조회 수: 19(최근 30일)
Viswanath Hariharan 2017년 12월 18일
답변: Irshad Khan 2018년 8월 10일
I have a matrix [5/8 3/8; 3/8 5/8] and it has more than one square root. If I perform sqrtm on it, it returns only one square root. How do I obtain all of its square roots?

댓글을 달려면 로그인하십시오.

### 답변(2개)

Walter Roberson 2017년 12월 19일
x = sym('x', [2 2]);
xsq = x^2;
sol = solve(xsq == [5/8 3/8; 3/8 5/8]);
all_roots = arrayfun(@(x11, x12, x21, x22) [x11,x12;x21,x22], sol.x1_1, sol.x1_2, sol.x2_1, sol.x2_2, 'uniform', 0);
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
Walter Roberson 2017년 12월 22일
T = sqrt(sym(2)); U = [-1/T -1/T;-1/T/2 1/T/2] double(U) %verify that U is the matrix you are talking about U^2
The result is
[ 3/4, 1/4]
[ 1/8, 3/8]
which is not your original matrix, so the matrix you indicate is not a square root of the original matrix.

댓글을 달려면 로그인하십시오.

How do I get only real roots?

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by