Reputation: 21
I'm learning how to use Matlab. I've a question about the matrix A: A=[1,2,3;4,5,6;7,8,9] Obviously the determinant should be equal to 0. But actually I got the value: 6.661338147750939e-016 What is wrong?
I know it's pretty much zero. What I want is to have zero as result. Is there a way to get 0 (precise result) or 6.661338147750939e-016 is all I can get?
Upvotes: 2
Views: 1103
Reputation: 23976
Matlab computes the determinant using LU decomposition, so the determinant is computed as a floating point number even for a matrix of integers. What you're seeing is the typical numerical error in floating point calculations.
If you're trying to check if the matrix is singular, this answer gives a bunch of alternatives that are better than using the determinant.
Upvotes: 3