From: Walter Roberson <>
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$>
References: <hn4a5i$j1p$>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: 1268103957 57 (9 Mar 2010 03:05:57 GMT)
NNTP-Posting-Date: Tue, 9 Mar 2010 03:05:57 +0000 (UTC)
User-Agent: Thunderbird (Macintosh/20090812)
In-Reply-To: <hn4a5i$j1p$>
Xref: 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.