def chck_posdef(A):
    if A[0,0]*A[1,1]>A[0,1]**2:
        print "positive definite therefore both +ve eigenvalues"
    else:
        print "not positive definite"
               
A1=matrix([[5,6],[6,7]])
A2=matrix([[-1,-2],[-2,-5]])
A3=matrix([[1,10],[10,100]])
A4=matrix([[1,10],[10,101]])
chck_posdef(A1)
out:not positive definite 

chck_posdef(A2)
out:positive definite therefore both +ve eigenvalues

chck_posdef(A3)
out:not positive definite

chck_posdef(A4)
out:positive definite therefore both +ve eigenvalues

Strang-317-16-U (last edited 2010-12-17 04:21:46 by rupampy)