Re: [R] Efficient testing for +ve definiteness

From: Spencer Graves <>
Date: Fri 15 Jul 2005 - 03:59:43 EST

          To reinforce Prof. Ripley's comment that, "Knowing the determinant does not tell you if the matrix is close to non-positive definite", note that the determinant of the negative of the identity matrix, (-diag(k)), is (-1)^k; if k is even, the determinant is positive. This silly example connects to real cases, as for example a 3x3 matrix of rank 1 with eigenvalues (1, -1e-20, -1e-21). The last two eigenvalues are buried in the noise relative to the largest (under standard double precision arithmatec).

          spencer graves

Prof Brian Ripley wrote:

> On Wed, 13 Jul 2005, Makram Talih wrote:

>>Dear R-users,
>>Is there a preferred method for testing whether a real symmetric matrix is
>>positive definite? [modulo machine rounding errors.]
>>The obvious way of computing eigenvalues via "E <- eigen(A, symmetric=T,
>>only.values=T)$values" and returning the result of "!any(E <= 0)" seems
>>less efficient than going through the LU decomposition invoked in
>>"determinant.matrix(A)" and checking the sign and (log) modulus of the
>>I suppose this has to do with the underlying C routines. Any thoughts or

> It has to do with what exactly you want to test. Knowing the determinant
> does not tell you if the matrix is close to non-positive definite or not.
> For numerical work, a comparison of the smallest eigenvalue to the largest
> is usually the most useful indication of possible problems in
> computations. An alternative is to try a Choleski decomposition, which
> may be faster but is less informative.
> Given how fast eigenvalues can be computed by current algorithms (and note
> the comments in ?eigen) I would suggest not worrying about speed until you
> need to (probably never).
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA <>
Tel:  408-938-4420
Fax: 408-280-7915

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Fri Jul 15 04:08:58 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:41 EST