[SciPy-user] verify whether a matrix is positive definite or not

Nils Wagner nwagner@iam.uni-stuttgart...
Thu Jun 28 06:31:57 CDT 2007

Hi all,

I have a parameter-dependent matrix

B(x) = B_0 + x B_1,  0 \le x \le 1

where B_0 and B_1 are symmetric. How can I determine critical values x*
(if any) such that B(x*) is not positive definite ?

from scipy import *

def B(x):

    return array(([[11.,8.],[8.,7.]])) - x*array(([[20.,1.],[1.,26]]))

X = linspace(0,1,100)

for x in X:
    print x

I mean it would be nice if cholesky could return info=1 if the matrix is
not spd.
The current behaviour is

Traceback (most recent call last):
  File "test_spd.py", line 11, in ?
  File "/usr/lib64/python2.4/site-packages/scipy/linalg/decomp.py", line
552, in cholesky
    if info>0: raise LinAlgError, "matrix not positive definite"
numpy.linalg.linalg.LinAlgError: matrix not positive definite

Helpful suggestions would be appreciated.


More information about the SciPy-user mailing list