Computing the determinant of a block matrix
9 ビュー (過去 30 日間)
古いコメントを表示
I am having trouble using a well-known formula for computing the determinant of a block matrix. That is, if
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1084345/image.png)
in which A and D are square matrices and
exists then
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1084350/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1084355/image.png)
The code snippet below should achieve this but it returns two different results. I'm sure it's a very trivial mistake I've made but I've probably been staring at it too long now to find it.
As a follow up, does anyone know if there is a suitably adjusted version of this formula for the case when it is B and C which are the square matrices?
function [detM,detBlock] = BlockDeterminant()
M = magic(4);
detM = det(M);
A = M(1:3,1:3);
B = M(1:3,4);
C = M(4,1:3);
D = M(4,4);
detBlock = det(A)*det(D-C*inv(A)*B);
end
0 件のコメント
採用された回答
KSSV
2022 年 8 月 1 日
A = rand(2) ;
B = rand(2) ;
C = rand(2) ;
D = rand(2) ;
M = [A B; C D] ;
det(M)
det(A)*det(D-C*inv(A)*B)
In your case, D is a scalar.
14 件のコメント
その他の回答 (1 件)
Walter Roberson
2022 年 8 月 1 日
Just round-off error. You are calculating two different order of operations and that affects the results .
If you use M = sym(magic(4)) you will get exact zero for each
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Operating on Diagonal Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!