math - matrix laws and syntax matlab -
what happening in code? don't understand why getting 2 different different matrices when a^-1 * b^-1 = (a*b)^-1 have tried writing in language keep getting same inequality.
input:
a = [3 5 2; 2 1 -1; 1 2 2]; b = [6 -2 4; 6 4 -12; 12 2 8]; inversea = a^(-1); inverseb = b^(-1); inversemult = inversea * inverseb; inversematmult = (a*b)^(-1); equalitycheck = inversemult == inversematmult; disp(inversemult) disp(inversematmult) disp(equalitycheck)
output:
-0.4038 -0.0863 0.1974 0.3224 0.0923 -0.1478 -0.1518 -0.0804 0.0804 -0.0317 0.0615 0.0694 0.1190 -0.2619 -0.1667 -0.0357 -0.0089 0.0625 0 0 0 0 0 0 0 0 0
you assuming incorrect identity - should be:
(a*b)^-1 = b^-1 * a^-1
(see useful list of invertible matrix identities here.)
so if change line:
inversematmult = (a*b)^(-1);
to:
inversematmult = (b*a)^(-1);
then should expected result. (note equality check may still fail due rounding errors, should see 2 result matrices identical reasonable number of significant figures.)
Comments
Post a Comment