Date: Apr 5, 2013 10:50 AM
Author: Steven Lord
Subject: Re: determinant calculation of integer matrices
"Bruno Luong" <firstname.lastname@example.org> wrote in message
> Someone asks me off line why det (magic(9) - 41) = 0. Here is how I see
> It is easy to check sum( magic(9) ) / 9 = 41
> 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 matrix
A = 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 system
n = 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.
To contact Technical Support use the Contact Us link on