From: "Steven_Lord" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: DETERMINANT OF 20 BY 20 MATRIX - higher precision for eigenvectors
Date: Thu, 14 Apr 2011 10:09:50 -0400
Organization: MathWorks
Lines: 115
Message-ID: <io6v73$a4a$>
References: <io5er6$cos$> <io5sg3$gmj$> <io6gmt$qth$>
Mime-Version: 1.0
Content-Type: text/plain;
Content-Transfer-Encoding: 7bit
X-Trace: 1302790179 10378 (14 Apr 2011 14:09:39 GMT)
NNTP-Posting-Date: Thu, 14 Apr 2011 14:09:39 +0000 (UTC)
In-Reply-To: <io6gmt$qth$>
X-Priority: 3
X-MSMail-Priority: Normal
Importance: Normal
X-Newsreader: Microsoft Windows Live Mail 14.0.8089.726
X-MimeOLE: Produced By Microsoft MimeOLE V14.0.8089.726
Xref: comp.soft-sys.matlab:721887

"Leo Kay" <> wrote in message 
> "Roger Stafford" wrote in message <io5sg3$gmj$>...
>> "Leo Kay" <> wrote in message 
>> <io5er6$cos$>...
>> > Hello,
>> > I am trying to work out the determinant of a 20 by 20 matrix in Matlab. 
>> > When I run det(M), Matlab simply stalls. I would not have suspected 
>> > this to be an issue. The matrix has lots of 0s and ALL ENTRIES ARE 
>> > EXPONENTIALS so I could theoretically take the log before fining the 
>> > det, but I dont wanna do that.
>> >
>> > Also, when I ask for the EIG(M), which is the eigenvectors, the 
>> > precision I obtain from Matlab is close to abysmal, as I need to find a 
>> > ridiculous number of eignvectors by averaging over entries of M, then 
>> > adding such vectors. The trouble is, unless precision is high, errors 
>> > add up exponentially fast in my problem.
>> >
>> >
>> > I mean I have formulated things as simply as I possibly coul so please 
>> > help.
>> - - - - - - - - - - -
>>   Your description of your problem does not make much sense to me.  You 
>> mention that you could take the logarithm of the matrix entries before 
>> finding its determinant (but "dont wanna",) but this is surely not how to 
>> find a determinant.  The determinant of element logarithms is not equal 
>> to the logarithm of the determinant, just as the logarithm of a product 
>> is not equal to the product of the logarithms of its factors.
>>   You state that your 20 x 20 matrix has a ridiculous number of 
>> eigenvectors.  Is 20 a ridiculous number?  That is the largest number it 
>> can have.  If M has a full set of 20 independent eigenvectors, then its 
>> determinant will be equal to the product of its eigenvalues.  Your 
>> statement that "The matrix has lots of 0s" would lead one to suspect that 
>> it might not have 20 independent eigenvectors, and it could well have a 
>> determinant value of zero.
>> Roger Stafford

I just reread Roger's comment and it seems to be fine to me. It seems to be 
more appropriate to someone who has little to no experience with 
determinants, eigenvectors, and eigenvalue computations, but nothing in your 
original message indicated to either Roger or I your level of experience. 
Perhaps you have a higher level of experience than Roger thought you did and 
that's why you thought it patronizing.

> First off I am looking for the zero eigenvalue.

So you're looking for a vector V such that M*V is the zero vector? In that 
case, you're not looking for an eigenvalue/eigenvector pair. You're looking 
for the null space of the matrix, and in that case you should use the NULL 
function instead of EIG.

> Secondly, by taking logarithm, I mean diagonalizing, then taking 
> exponential of the log trace. BUT I DONT WANNA DO THAT BECAUSE I HAVE 

That's a VERY important detail that you left out of your original message!

Finding the eigenvalues of a general symbolic matrix requires finding the 
roots of a polynomial of order equal to the number of rows in the matrix.

Depending on how complicated the coefficients in your matrix are, this could 
be very difficult or even IMPOSSIBLE to solve generally.

> Please, let's not be patronizing, by ridiculous amount of eigenvectors, I 
> meant after averaging (ie, randomize entries, and find a ridicuous amount 
> fof eigenvectors, say 10 000), so I need high precision.

That statement makes no sense to me, unless you're doing some sort of Monte 
Carlo problem where the entries of your matrix are randomly generated and 
you expect the eigenvalues and eigenvectors of those random matrices to 
converge. Please clarify what exactly you're doing.

Also, it's often _not_ the case that simply throwing higher precision at the 
problem is the correct solution to difficulties you may be experiencing.

> Anyways, can anyone tell me why finding the determininant of a 20 y 20 
> symbolic matrix  fails?

Why are you computing the determinant? If you're computing the determinant 
to try to decide if the matrix is singular, that's a BAD IDEA. Use the 
condition number instead.

As an example:

A = (1e-20)*eye(20);

The determinant of A is 0 (it underflows in double precision) so A is 
singular, right? But the condition number is 1, indicating that A is well 
conditioned. In fact, A does have an exact inverse:

Ainv = (1e20)*eye(20);
norm(A*Ainv-eye(20)) % 0
norm(Ainv*A-eye(20)) % 0

Steve Lord
To contact Technical Support use the Contact Us link on