필터 지우기
필터 지우기

Computing the determinant of a block matrix

조회 수: 17 (최근 30일)
RickyBoy
RickyBoy 2022년 8월 1일
편집: RickyBoy 2022년 8월 1일
I am having trouble using a well-known formula for computing the determinant of a block matrix. That is, if
in which A and D are square matrices and exists then
.
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

채택된 답변

KSSV
KSSV 2022년 8월 1일
A = rand(2) ;
B = rand(2) ;
C = rand(2) ;
D = rand(2) ;
M = [A B; C D] ;
det(M)
ans = -0.0221
det(A)*det(D-C*inv(A)*B)
ans = -0.0221
In your case, D is a scalar.
  댓글 수: 14
RickyBoy
RickyBoy 2022년 8월 1일
편집: RickyBoy 2022년 8월 1일
Aha!
OK, so for a bit of enlightenment, @Bruno Luong, let me demonstrate how this is so helpful...
In my setup (and it happens to be that . Therefore using detBlockAlt, we can achieve
.
Which is a much simpler form of the determinant than a general formulation will result in.
Thank you so much for your engagement!
Bruno Luong
Bruno Luong 2022년 8월 1일
Good. I don't get why contribution is so helpful, but if you say so...

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

추가 답변 (1개)

Walter Roberson
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

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by