ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 12 Dec 2016 10:01:39 -0600quadraticform rational_diagonal_form?http://ask.sagemath.org/question/35985/quadraticform-rational_diagonal_form/I don't understand the factor of "2" ; which also appears in my real problem.
Here is the sample code from
doc.sagemath.org/html/en/reference/quadratic_forms/sage/quadratic_forms/quadratic_form.html#sage.quadratic_forms.quadratic_form.QuadraticForm.rational_diagonal_form
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]
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().**
RayMon, 12 Dec 2016 09:34:50 -0600http://ask.sagemath.org/question/35985/quadraticform-rational_diagonal_form/Answer by rrogers for <p>I don't understand the factor of "2" ; which also appears in my real problem.
Here is the sample code from
doc.sagemath.org/html/en/reference/quadratic_forms/sage/quadratic_forms/quadratic_form.html#sage.quadratic_forms.quadratic_form.QuadraticForm.rational_diagonal_form </p>
<pre><code>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 ]
</code></pre>
<p>but </p>
<pre><code>T.transpose() * Q.matrix() * T
[ -1/8 0 0 0]
[ 0 8 0 0]
[ 0 0 26 0]
[ 0 0 0 563/26]
</code></pre>
<p>Off by a factor of 2? </p>
<p>The description says. </p>
<pre><code>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().**
</code></pre>
<p>Ray</p>
http://ask.sagemath.org/question/35985/quadraticform-rational_diagonal_form/?answer=35986#post-id-35986Q.matrix() ( i.e. the .matrix() operation) returns
matrix()
Returns the Hessian matrix A for which Q(X) = (1/2)∗Xt∗A∗X(1/2)∗Xt∗A∗X.
I can understand where the two comes from if your doing differentiation.
What I don't understand is why .matrix() gives this form.
Ray
Mon, 12 Dec 2016 10:01:39 -0600http://ask.sagemath.org/question/35985/quadraticform-rational_diagonal_form/?answer=35986#post-id-35986