Matlab
>> H=hilb(4);H1=inv(H),norm(H*H1-eye(4))
H1 =
1.0e+03 *
0.0160 -0.1200 0.2400 -0.1400
-0.1200 1.2000 -2.7000 1.6800
0.2400 -2.7000 6.4800 -4.2000
-0.1400 1.6800 -4.2000 2.8000
ans =
2.8455e-13
矩阵维数较大,警告: 矩阵接近奇异值,或者缩放错误。结果可能不准确。RCOND = 1.334996e-18。
Matlab
>> H=sym(hilb(7));H1=inv(H)%7*7逆矩阵
H1 =
[ 49, -1176, 8820, -29400, 48510, -38808, 12012]
[ -1176, 37632, -317520, 1128960, -1940400, 1596672, -504504]
[ 8820, -317520, 2857680, -10584000, 18711000, -15717240, 5045040]
[-29400, 1128960, -10584000, 40320000, -72765000, 62092800, -20180160]
[ 48510, -1940400, 18711000, -72765000, 133402500, -115259760, 37837800]
[-38808, 1596672, -15717240, 62092800, -115259760, 100590336, -33297264]
[ 12012, -504504, 5045040, -20180160, 37837800, -33297264, 11099088]
>> H=sym(hilb(50));norm(H*inv(H)-eye(size(H)))
ans =
0
>> A=[16 2 3 13; 5 11 10 8; 9 7 6 12; 4 14 15 1]; B=inv(A), A*B
警告: 矩阵接近奇异值,或者缩放错误。结果可能不准确。RCOND = 4.625929e-18。
B =
1.0e+15 *
-0.2649 -0.7948 0.7948 0.2649
-0.7948 -2.3843 2.3843 0.7948
0.7948 2.3843 -2.3843 -0.7948
0.2649 0.7948 -0.7948 -0.2649
ans =
1.5000 0 2.0000 0.5000
-1.0000 -2.0000 3.0000 2.2500
-0.5000 -4.0000 4.0000 0.5000
-1.1250 -5.2500 5.3750 3.0312
Matlab
>> inv(A)%符号运算,说明A奇异矩阵
ans =
[Inf, Inf, Inf, Inf]
[Inf, Inf, Inf, Inf]
[Inf, Inf, Inf, Inf]
[Inf, Inf, Inf, Inf]
Matlab
>> a=sym('a%d',[1,4]); H=hankel(a); inv(H)
ans =
[ 0, 0, 0, 1/a4]
[ 0, 0, 1/a4, -a3/a4^2]
[ 0, 1/a4, -a3/a4^2, -(- a3^2 + a2*a4)/a4^3]
[1/a4, -a3/a4^2, -(- a3^2 + a2*a4)/a4^3, -(a3^3 - 2*a2*a3*a4 + a1*a4^2)/a4^4]
伪逆矩阵穆尔-彭罗斯广义逆矩阵_百度百科 (baidu.com)
Matlab
>> A=[16 2 3 13; 5 11 10 8; 9 7 6 12; 4 14 15 1]; B=pinv(A),A*B
B =
0.1011 -0.0739 -0.0614 0.0636
-0.0364 0.0386 0.0261 0.0011
0.0136 -0.0114 -0.0239 0.0511
-0.0489 0.0761 0.0886 -0.0864
ans =
0.9500 -0.1500 0.1500 0.0500
-0.1500 0.5500 0.4500 0.1500
0.1500 0.4500 0.5500 -0.1500
0.0500 0.1500 -0.1500 0.9500
奇异矩阵的伪逆
Matlab
>> norm(A*B*A-A), norm(B*A*B-B),norm(A*B-(A*B)'), norm(B*A-(B*A)')
ans =
1.5830e-14
ans =
4.8420e-17
ans =
6.5232e-16
ans =
8.5181e-16
Matlab
>> pinv(B), norm(ans-A)
ans =
16.0000 2.0000 3.0000 13.0000
5.0000 11.0000 10.0000 8.0000
9.0000 7.0000 6.0000 12.0000
4.0000 14.0000 15.0000 1.0000
ans =
2.0603e-14
对得到的伪逆再求一次伪逆,就可以还原出来原矩阵
Matlab
>> A=[6,1,4,2,1; 3,0,1,4,2; -3,-2,-5,8,4]; rank(A)%秩=2
ans =
2 %长方形,奇异矩阵
>> iA=pinv(A), norm(A*iA*A-A), norm(iA*A-A'*iA'), norm(iA*A-A'*iA'), norm(A*iA-iA'*A')
iA =
0.0730 0.0413 -0.0221
0.0108 0.0020 -0.0156
0.0459 0.0178 -0.0385
0.0327 0.0431 0.0638
0.0164 0.0215 0.0319
ans =
6.4142e-15
ans =
2.8268e-16
ans =
2.8268e-16
ans =
1.4947e-16