Why is the output of inv() and pinv() not equal in Matlab and Octave?

前端 未结 3 860
死守一世寂寞
死守一世寂寞 2021-01-17 11:33

I have noticed that if A is a NxN matrix and it has the inverse matrix. But what the inv() and pinv() function output is different. - My environment is Win7x64 SP1, Matlab

3条回答
  •  深忆病人
    2021-01-17 11:53

    Floating point arithmetic has a certain precision, you can not rely on equality. To avoid such errors, you could try to work with the symbolic toolbox of matlab.

    Very simple line of code in octave to demonstrate the problems:

    >>> (1/48)*48==(1/49)*49
    ans = 0
    >>> (1/48)*48-(1/49)*49
    ans =  1.1102e-16
    >>>
    

提交回复
热议问题