# Revision history [back]

### Find out if matrix is positive semidefinite

What can I do to find out if a real or complex (symmetric/hermitian) matrix is positive definite (or better: positive semidefinite).

More specifically, the following code doesn't work:

reset()
f(t) = exp(I*t)
ts = [random() for k in range(3)]
var('k, l')
mm = matrix(CC,len(ts))
for k in range(1,len(ts)):
for l in range(1,len(ts)):
mm[k,l] = f(ts[k] - ts[l])
mm.is_positive_definite()

It gives the error:

TypeError: entries of the matrix must be in an exact ring, not Complex
Field with 53 bits of precision
 2 retagged FrédéricC 5141 ●3 ●43 ●112

### Find out if matrix is positive semidefinite

What can I do to find out if a real or complex (symmetric/hermitian) matrix is positive definite (or better: positive semidefinite).

More specifically, the following code doesn't work:

reset()
f(t) = exp(I*t)
ts = [random() for k in range(3)]
var('k, l')
mm = matrix(CC,len(ts))
for k in range(1,len(ts)):
for l in range(1,len(ts)):
mm[k,l] = f(ts[k] - ts[l])
mm.is_positive_definite()

It gives the error:

TypeError: entries of the matrix must be in an exact ring, not Complex
Field with 53 bits of precision