Opened 11 years ago

Closed 10 years ago

(reduced) norm of quaternion ideals is broken

Reported by: Owned by: daniels AlexGhitza major sage-5.3 algebra quaternion, ideal sage-5.3.beta1 Daniel Smertnig Aly Deines N/A

Description

1.) The norm of an ideal in quaternion algebra is off by a factor of 2

sage: A.<i,j,k> = QuaternionAlgebra(-1,-1)
sage: I = A.ideal([i,j,k,1/2 + 1/2*i + 1/2*j + 1/2*k])      # this is actually an order, so has reduced norm 1
sage: I.left_order()
sage: I.norm()
2

The reason is that the norm is computed from d(I)=n(I)2 d(R) where R is the left- or right-order of I and d(I) = \sqrt{ abs{det(tr(x_i \conj{x_j}))} } for a ZZ-basis (x_i) of I. But the matrix returned by gram_matrix() that is actually used in the computation has as entries 2*tr(x_i \conj{x_j}), thus the determinant is off by a factor of 16 and the resulting reduced norm off by a factor of 2

2.) Omitting the line 'I.left_order()' in the previous example gives a RuntimeError?:

sage: A.<i,j,k> = QuaternionAlgebra(-1,-1)
sage: I = A.ideal([i,j,k,1/2 + 1/2*i + 1/2*j + 1/2*k])
sage: I.norm()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)

/home/daniel/<ipython console> in <module>()

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/algebras/quatalg/quaternion_algebra.pyc in norm(self)
1973         assert r.is_square(), "first is bad!"
1974         r = r.sqrt()
-> 1975         r/= self.quaternion_order().discriminant()
1976         assert r.is_square(), "second is bad!"
1977         return r.sqrt()

/opt/sage-4.8-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux/local/lib/python2.6/site-packages/sage/algebras/quatalg/quaternion_algebra.pyc in quaternion_order(self)
1692             A = self.__right_order
1693         else:
-> 1694             raise RuntimeError, "unable to determine quaternion order of ideal without known order"
1695         self.__quaternion_order = A
1696         return A

RuntimeError: unable to determine quaternion order of ideal without known order

This is because neither the left- nor the right-order of I have been computed at this point. There is however no mathematical reason why this should fail.

comment:1 follow-up:  2 Changed 11 years ago by daniels

The patch corrects both mentioned problems, and adds a doctest to test for this.

Some of the old doctests seem to have wrong values for the norm (which is why they passed). I changed them and cross-checked with Magma that the ideals appearing in the doctests indeed have the new values as reduced norms.

comment:2 in reply to:  1 ; follow-up:  3 Changed 11 years ago by dkrenn

[...] I changed them and cross-checked with Magma that the ideals appearing in the doctests indeed have the new values as reduced norms.

You could add an additonal doc-test with " # optional - magma" as comment, so that the mentioned cross-check is also included.

comment:3 in reply to:  2 Changed 11 years ago by daniels

You could add an additonal doc-test with " # optional - magma" as comment, so that the mentioned cross-check is also included.

I updated the patch to do this for the first doctest.

I also noticed that the other 'optional - magma' doctests fail on my Version of Magma (V2.18-4) because the output format has slightly changed from what Sage expects, but I suppose the fix for that should not be mixed with this ticket.

comment:4 Changed 11 years ago by daniels

Status: new → needs_review

comment:5 Changed 11 years ago by aly.deines

Status: needs_review → positive_review