2

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?

  • Nothing's wrong. Just numerical inaccuracies. The error is of the order of [eps](http://www.mathworks.es/es/help/matlab/ref/eps.html), so it's normal – Luis Mendo Dec 29 '13 at 04:33

1 Answers1

3

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.

Community
  • 1
  • 1
Tim Goodman
  • 23,308
  • 7
  • 64
  • 83