Error in Python matrix calculation
In this case, if the matrix is not a square matrix, the following error will appear:
It is worth noting that when we use it in this way, the program will run normally
It seems that we have obtained the inverse of a non square matrix
Now let’s verify:
If you look at it carefully, it’s not a unit array. I think this method is not feasible, but with the idea of blog rigor, I decided to see the results of the square array
seeing here, I found that the inversion of square matrix also appeared abnormal. I can’t help but look carefully. The original term which should be 0 is very small. Friends who have studied numerical analysis should know that this is a non-zero problem caused by the rounding error of computer, so we can regard both as unit matrix
note: don’t convert the data type at will here, because converting the data type will result in the loss of data accuracy. For example, the unit matrix mentioned above will change when converting the data type, and a bit on the diagonal line may become 0. the unit matrix mentioned above will change when converting the data type