```Date: Apr 5, 2013 10:50 AM
Author: Steven Lord
Subject: Re: determinant calculation of integer matrices

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message news:kjklfi\$il6\$1@newscl01ah.mathworks.com...> Someone asks me off line why det (magic(9) - 41)  = 0. Here is how I see > it:>> It is easy to check sum( magic(9) ) / 9  = 41>> Thus> sum(magic(9) - 41) = 0.>> That means>> (magic(9) - 41) * ones(9,1) = 0.>> Therefore A = (magic(9) - 41) is not full rank (because A*x = 0 has non > trivial solution).>> So det (magic(9) - 41)  = 0.Taking this a little further aside, if you want to tell if a matrix is singular or not, do NOT use DET.% Sample matrixA = 0.1*eye(400);d = det(A)% Since this is 0, A is singular! Right???c = cond(A)% But it's well conditioned!s = svd(A);ms = max(abs(s-0.1))% All singular values are extremely close to 0.1. That's good, right?x = rand(400, 1);y = A\x;% MATLAB has no problem solving this systemn = norm(A*y-x)% The residual norm should be very small which is another good sign.% How do we reconcile this with the fact that DET told us A is singular?Use COND or RCOND for singularity checking instead.-- Steve Lordslord@mathworks.comTo contact Technical Support use the Contact Us link on http://www.mathworks.com
```