# Revision history [back]

D, T = Q.rational_diagonal_form(return_matrix=True)
D
[ -1/16 0 0 0 ]
[ * 4 0 0 ]
[ * * 13 0 ]
[ * * * 563/52 ]
but
T.transpose() * Q.matrix() * T
[ -1/8 0 0 0]
[ 0 8 0 0]
[ 0 0 26 0]
[ 0 0 0 563/26]

Off by a factor of 2?

The description says.
OUTPUT: either D (if return_matrix is false) or (D,T) (if return_matrix is true) where
D – the diagonalized form of this quadratic form.
T – transformation matrix. This is such that T.transpose() * self.matrix() * T gives D.matrix().**

Ray

 2 None kcrisman 11857 ●36 ●119 ●237

Q = QuadraticForm(ZZ, 4, range(10))
D, T = Q.rational_diagonal_form(return_matrix=True)
D
[ -1/16 0 0 0 ]
[ * 4 0 0 ]
[ * * 13 0 ]
[ * * * 563/52 ]  ]


but

T.transpose() * Q.matrix() * T
[  -1/8      0      0      0]
[     0      8      0      0]
[     0      0     26      0]
[     0      0      0 563/26]
[     0      0      0 563/26]


Off by a factor of 2?

The description says.

OUTPUT: either D (if return_matrix is false) or (D,T) (if return_matrix is true) where
D – the diagonalized form of this quadratic form.
T – transformation matrix. This is such that T.transpose() * self.matrix() * T gives D.matrix().**   Ray  D.matrix().**


Ray