Congruence of two non-positive definite matrices

asked 2023-12-11 17:10:05 +0200

azerbajdzan gravatar image

Method here works only with positive definite matrices.

How to adapt it so that it works with non-positive definite matrices?

Both matrices a and b are positive definite:

a=matrix(2, 2, [5,2,2,3])
b=matrix(2, 2, [4,1,1,3])
print(a.is_positive_definite())
print(b.is_positive_definite())
qa=QuadraticForm(ZZ,a + a.transpose())
qb=QuadraticForm(ZZ,b + b.transpose())
x=qb.is_globally_equivalent_to(qa, return_matrix=True)
print(x)
print(x.transpose()*a*x==b)

True
True
[-1  0]
[ 1  1]
True

Here matrices a and b are not positive definite (which gives error):

a=matrix(2, 2, [6, 3, 3, 1])
b=matrix(2, 2, [6, -15, -15, 37])
print(a.is_positive_definite())
print(b.is_positive_definite())
qa=QuadraticForm(ZZ,a + a.transpose())
qb=QuadraticForm(ZZ,b + b.transpose())
x=qb.is_globally_equivalent_to(qa, return_matrix=True)

False
False

ValueError: not a definite form in QuadraticForm.is_globally_equivalent_to()

But there are at least these solutions for x:

[[-1,2],[0,1]]
[[-1,2],[6,-13]]
[[-1,3],[0,-1]]
[[-1,3],[6,-17]]
[[1,-3],[-6,17]]
[[1,-3],[0,1]]
[[1,-2],[-6,13]]
[[1,-2],[0,-1]]

Which can be verified by:

x=matrix([[-1,2],[6,-13]])
x.transpose()*a*x==b

True
edit retag flag offensive close merge delete