MATLAB returns a wrong value of determinant.
Ältere Kommentare anzeigen
Consider a 2x2 Matrix X whose entries are
5 25
7 35
By hand calculations, we know that the determinant of the Matrix is 0. How come when MATLAB computes this, it gives a value of 3.8858e-15? Here's the Code snippet.
Using also MATLAB R2021b
X =[5 25; 7 35];
D = det(X)
Akzeptierte Antwort
Weitere Antworten (1)
Jon
am 10 Nov. 2021
0 Stimmen
There will always be some tolerance in numerical methods compared with exact solutions. 3.88858e-15 is considered very small, and effectively can be treated as zero. It is important to realize this whenever working with numerical methods particularly when testing for certain conditions. You should always define a threshold for what is considered close enough to zero. One useful value you can get to help you scale this is the machine precision, which you can get using MATLAB's eps function. You can then define zero as being some multiple of the machine precision.
1 Kommentar
The reason behind this is that Matlab stores data with finite memory, which might not be enough to yield the mathematically correct answer.
The reason you should consider a value of 1e-15 as 0 is precisely this.
det([5 25;7 35]*1e-15)
Here you see the exact same thing. I personally treat every value 15 orders of magnitude smaller than the input numbers as 0. If you need more precision, you shouldn't be using the standard tools.
Kategorien
Mehr zu Matrix Computations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!