#8977: Bug in QuadraticForm.rational_diagonal_form()
-------------------------------+--------------------------------------------
Reporter: gdrama | Owner: justin
Type: defect | Status: new
Priority: minor | Milestone:
Component: quadratic forms | Keywords: rational_diagonal_form()
Author: | Upstream: N/A
Reviewer: | Merged:
Work_issues: |
-------------------------------+--------------------------------------------
Description changed by gdrama:
Old description:
> The function rational_diagonal_form() fails in some quadratic forms. For
> example:
> {{{
> sage: Q = QuadraticForm(ZZ,2,[0,1,-1])
> sage: Q
> Quadratic form in 2 variables over Integer Ring with coefficients:
> [ 0 1 ]
> [ * -1 ]
>
> sage: Q.rational_diagonal_form()
> ---------------------------------------------------------------------------
> ZeroDivisionError Traceback (most recent call
> last)
>
> /home/gustavo/<ipython console> in <module>()
>
> /home/gustavo/sage-4.3.3/local/lib/python2.6/site-
> packages/sage/quadratic_forms/quadratic_form__local_field_invariants.pyc
> in rational_diagonal_form(self, return_matrix)
> 113 for j in range(i+1, n):
> 114 if Q[i,j] != 0:
> --> 115 temp[i,j] = -Q[i,j] / (Q[i,i] * 2) ## This
> should only occur when Q[i,i] != 0, which the above step guarantees.
> 116
> 117 Q = Q(temp)
>
> /home/gustavo/sage-4.3.3/local/lib/python2.6/site-
> packages/sage/structure/element.so in
> sage.structure.element.RingElement.__div__
> (sage/structure/element.c:11882)()
>
> /home/gustavo/sage-4.3.3/local/lib/python2.6/site-
> packages/sage/rings/rational.so in sage.rings.rational.Rational._div_
> (sage/rings/rational.c:14641)()
>
> ZeroDivisionError: Rational division by zero
> }}}
New description:
The function rational_diagonal_form() fails in some quadratic forms. For
example:
{{{
sage: Q = QuadraticForm(ZZ,2,[0,1,-1])
sage: Q
Quadratic form in 2 variables over Integer Ring with coefficients:
[ 0 1 ]
[ * -1 ]
sage: Q.rational_diagonal_form()
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call
last)
/home/gustavo/<ipython console> in <module>()
/home/gustavo/sage-4.3.3/local/lib/python2.6/site-
packages/sage/quadratic_forms/quadratic_form__local_field_invariants.pyc
in rational_diagonal_form(self, return_matrix)
113 for j in range(i+1, n):
114 if Q[i,j] != 0:
--> 115 temp[i,j] = -Q[i,j] / (Q[i,i] * 2) ## This
should only occur when Q[i,i] != 0, which the above step guarantees.
116
117 Q = Q(temp)
/home/gustavo/sage-4.3.3/local/lib/python2.6/site-
packages/sage/structure/element.so in
sage.structure.element.RingElement.__div__
(sage/structure/element.c:11882)()
/home/gustavo/sage-4.3.3/local/lib/python2.6/site-
packages/sage/rings/rational.so in sage.rings.rational.Rational._div_
(sage/rings/rational.c:14641)()
ZeroDivisionError: Rational division by zero
}}}
When an element of the diagonal is zero the algorithm tries, with a
tranformation, to eliminate it. But in the case that Q[i,i]=0, Q[i,j]!=0
and Q[j,j]=-Q[i,j] the tranformation brings the zero back.
The fix changes the transformation, in the case mentioned above, so that
doesn't happen.
--
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8977#comment:2>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.