Is the resulting accuracy on matrix manipulation any ill-logical?

送分小仙女□ 提交于 2019-12-02 02:53:56

问题


octave:1> A = [1 2 3; 4 5 6; 7 8 9]

octave:2> B = pinv (A)

octave:3> I = eye (size (A))
ans =

Diagonal Matrix

   1   0   0
   0   1   0
   0   0   1

octave:4> I2 = A * B
ans =

   0.83333   0.33333  -0.16667
   0.33333   0.33333   0.33333
  -0.16667   0.33333   0.83333

octave:5> A2 = A * I2
ans =

   1.00000   2.00000   3.00000
   4.00000   5.00000   6.00000
   7.00000   8.00000   9.00000

Why could the final Step 5 result in the perfect accuracy although the previous Step 4 in the unforgiving accuracy?

@EDIT

octave:6> format long

octave:7> I2
I2 =

   0.833333333333332   0.333333333333332  -0.166666666666666
   0.333333333333332   0.333333333333333   0.333333333333334
  -0.166666666666668   0.333333333333333   0.833333333333334

octave:8> A2
A2 =

   0.999999999999993   1.999999999999997   3.000000000000005
   3.999999999999982   4.999999999999992   6.000000000000014
   6.999999999999972   7.999999999999987   9.000000000000021

回答1:


The result does have errors, it's just that your display settings are such that everything is rounded to 4 decimal places (format short). If we change the display format (format long), we can see the errors:

format long

A * I2

%   0.999999999999990   1.999999999999998   3.000000000000007
%   3.999999999999978   4.999999999999993   6.000000000000017
%   6.999999999999965   7.999999999999987   9.000000000000027

Alternately, you can use num2str to show any arbitrary number of places after the decimal point.

% Show 32 places after the decimal point
num2str(A * I2, 32)

As for why A * pinv(A) * A is approximately equal to A, that is one of the defining properties of the Moore–Penrose pseudo-inverse computed by pinv.



来源:https://stackoverflow.com/questions/38516756/is-the-resulting-accuracy-on-matrix-manipulation-any-ill-logical

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!