Path: news.mathworks.com!newsfeed-00.mathworks.com!solaris.cc.vt.edu!news.vt.edu!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!not-for-mail
From: Walter Roberson <roberson@hushmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: given matrix, sum of diagonal elements
Date: Mon, 08 Mar 2010 21:05:56 -0600
Organization: The University of Manitoba
Lines: 9
Message-ID: <hn4dul$1p$1@canopus.cc.umanitoba.ca>
References: <hn4a5i$j1p$1@fred.mathworks.com>
NNTP-Posting-Host: ssh.ibd.nrc.ca
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: canopus.cc.umanitoba.ca 1268103957 57 132.246.132.10 (9 Mar 2010 03:05:57 GMT)
X-Complaints-To: abuse@cc.umanitoba.ca
NNTP-Posting-Date: Tue, 9 Mar 2010 03:05:57 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812)
In-Reply-To: <hn4a5i$j1p$1@fred.mathworks.com>
Xref: news.mathworks.com comp.soft-sys.matlab:615136

Enosh Bale wrote:
> that, given a square matrix, returns the sum of the diagonal elements.

Create a new matrix B, which is the same size as the original matrix, A, 
but only has the diagonal elements of A. Calculate the determinant of B. 
The determinant will be the product of the eigenvalues, so factor the 
determinant to get the eigenvalues. The sum of the eigenvalues of a 
diagonal matrix is equal to the sum of the diagonal elements of the 
matrix, so sum the factors you found to get the desired result.