Thank you for figuring that out! Shall we alert the developers about it? It 
is my first time on that forum, I am not sure I know how to do that...

And what about the behavior that occurs when we try to use the field AA:


sage: a=sqrt(AA(2))
sage: 
Q=QuadraticForm(AA,8,[1/2,-a/2,0,0,0,0,0,0,1/2,-a/2,0,0,0,0,0,1/2,-1/2,0,0
....: ,0,0,1/2,-1/2,0,0,0,1/2,-1/2,0,0,1/2,-a/2,0,1/2,-a/2,1/2])
sage: Q.signature_vector()
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-146-fedf8894b12c> in <module>()
----> 1 Q.signature_vector()

/opt/sagemath-8.6/local/lib/python2.7/site-packages/sage/quadratic_forms/quadratic_form__local_field_invariants.pyc
 
in signature_vector(self)
    329
    330     """
--> 331     diag = self.rational_diagonal_form()
    332     p = 0
    333     n = 0

/opt/sagemath-8.6/local/lib/python2.7/site-packages/sage/quadratic_forms/quadratic_form__local_field_invariants.pyc
 
in rational_diagonal_form(self, return_matrix)
    175     # Quadratic forms do not support immutability, so we need to 
make
    176     # a copy to be safe.
--> 177     Q = deepcopy(Q)
    178
    179     if return_matrix:

/opt/sagemath-8.6/local/lib/python2.7/copy.pyc in deepcopy(x, memo, _nil)
    188                             raise Error(
    189                                 "un(deep)copyable object of type 
%s" % cls)
--> 190                 y = _reconstruct(x, rv, 1, memo)
    191
    192     memo[d] = y

/opt/sagemath-8.6/local/lib/python2.7/copy.pyc in _reconstruct(x, info, 
deep, memo)
    332     if state is not None:
    333         if deep:
--> 334             state = deepcopy(state, memo)
    335         if hasattr(y, '__setstate__'):
    336             y.__setstate__(state)

/opt/sagemath-8.6/local/lib/python2.7/copy.pyc in deepcopy(x, memo, _nil)
    161     copier = _deepcopy_dispatch.get(cls)
    162     if copier:
--> 163         y = copier(x, memo)
    164     else:
    165         try:

/opt/sagemath-8.6/local/lib/python2.7/copy.pyc in _deepcopy_dict(x, memo)
    255     memo[id(x)] = y
    256     for key, value in x.iteritems():
--> 257         y[deepcopy(key, memo)] = deepcopy(value, memo)
    258     return y
    259 d[dict] = _deepcopy_dict

/opt/sagemath-8.6/local/lib/python2.7/copy.pyc in deepcopy(x, memo, _nil)
    161     copier = _deepcopy_dispatch.get(cls)
    162     if copier:
--> 163         y = copier(x, memo)
    164     else:
    165         try:

/opt/sagemath-8.6/local/lib/python2.7/copy.pyc in _deepcopy_list(x, memo)
    228     memo[id(x)] = y
    229     for a in x:
--> 230         y.append(deepcopy(a, memo))
    231     return y
    232 d[list] = _deepcopy_list

/opt/sagemath-8.6/local/lib/python2.7/copy.pyc in deepcopy(x, memo, _nil)
    188                             raise Error(
    189                                 "un(deep)copyable object of type 
%s" % cls)
--> 190                 y = _reconstruct(x, rv, 1, memo)
    191
    192     memo[d] = y

/opt/sagemath-8.6/local/lib/python2.7/copy.pyc in _reconstruct(x, info, 
deep, memo)
    326         dictiter = None
    327     if deep:
--> 328         args = deepcopy(args, memo)
    329     y = callable(*args)
    330     memo[id(x)] = y

/opt/sagemath-8.6/local/lib/python2.7/copy.pyc in deepcopy(x, memo, _nil)
    161     copier = _deepcopy_dispatch.get(cls)
    162     if copier:
--> 163         y = copier(x, memo)
    164     else:
    165         try:

/opt/sagemath-8.6/local/lib/python2.7/copy.pyc in _deepcopy_tuple(x, memo)
    235     y = []
    236     for a in x:
--> 237         y.append(deepcopy(a, memo))
    238     d = id(x)
    239     try:

... last 4 frames repeated, from the frame below ...

/opt/sagemath-8.6/local/lib/python2.7/copy.pyc in deepcopy(x, memo, _nil)
    188                             raise Error(
    189                                 "un(deep)copyable object of type 
%s" % cls)
--> 190                 y = _reconstruct(x, rv, 1, memo)
    191
    192     memo[d] = y

RuntimeError: maximum recursion depth exceeded
sage:


On Friday, October 18, 2019 at 6:38:50 AM UTC-5, Frédéric Chapoton wrote:
>
> The bug over the cyclotomic field is caused by
>
>
> sage: K = CyclotomicField(8)
> sage: K(-1/16) > 0
> True
>
>
>
> Le vendredi 18 octobre 2019 13:24:51 UTC+2, Frédéric Chapoton a écrit :
>>
>> This works (in sage 8.9) when using
>>
>> K.<z>=QuadraticField(2)
>>
>>
>>
>> Le vendredi 18 octobre 2019 02:12:02 UTC+2, Ignat Soroko a écrit :
>>>
>>> I am computing the signature of a quadratic form having entries 0, 1, 
>>> -1/2, -sqrt(2)/2. I noticed that the result of signature_vector() is 
>>> different if we treat the number sqrt(2) as a cyclotomic or as a real 
>>> number. Please look at the example:
>>>
>>> sage: K.<z>=CyclotomicField(8)
>>> sage: a=z-z^3  # a is a square root of 2
>>> sage: a-sqrt(2)
>>> 0
>>> sage: 
>>> Q=QuadraticForm(K,8,[1/2,-a/2,0,0,0,0,0,0,1/2,-a/2,0,0,0,0,0,1/2,-1/2,0,0,
>>> ....: 0,0,1/2,-1/2,0,0,0,1/2,-1/2,0,0,1/2,-a/2,0,1/2,-a/2,1/2])
>>> sage: Q.signature_vector()
>>> (8, 0, 0)
>>>
>>> this cannot be true since there exists an isotropic vector:
>>>
>>> sage: v=vector([1,a,1,0,0,0,0,0])
>>> sage: v*Q.matrix()*v
>>> 0
>>>
>>> Let's try it over reals:
>>>
>>> sage: a=sqrt(2)
>>> sage: 
>>> Q=QuadraticForm(RR,8,[1/2,-a/2,0,0,0,0,0,0,1/2,-a/2,0,0,0,0,0,1/2,-1/2,0,0
>>> ....: ,0,0,1/2,-1/2,0,0,0,1/2,-1/2,0,0,1/2,-a/2,0,1/2,-a/2,1/2])
>>> sage: Q.signature_vector()
>>> (6, 2, 0)
>>>
>>> however, the isotropic vector above is not isotropic anymore:
>>>
>>> sage: v=vector([1,a,1,0,0,0,0,0])
>>> sage: v*Q.matrix()*v
>>> sqrt(2)*(1.00000000000000*sqrt(2) - 1.41421356237310) - 
>>> 1.41421356237310*sqrt(2) + 2.00000000000000
>>>
>>> I also tried to define 
>>>
>>> sage: a=sqrt(AA(2))
>>> sage: 
>>> Q=QuadraticForm(AA,8,[1/2,-a/2,0,0,0,0,0,0,1/2,-a/2,0,0,0,0,0,1/2,-1/2,0,0
>>> ....: ,0,0,1/2,-1/2,0,0,0,1/2,-1/2,0,0,1/2,-a/2,0,1/2,-a/2,1/2])
>>>
>>> but Q.signature_vector() gives a runtime error with many lines of code 
>>> ending in:
>>>
>>> RuntimeError: maximum recursion depth exceeded
>>>
>>>
>>> Questions:
>>> 1) is Q.signature_vector() over cyclotomic field is interpreted in some 
>>> other way than for reals, thus making the result (8,0,0) somehow correct?
>>>
>>> 2) Which setting would guarantee both the correct result for 
>>> signature_vector() using the exact arithmetic and at the same time show 
>>> that v is actually an isotropic vector?
>>>
>>> Thank you!
>>>
>>>
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/736cec4c-073a-4960-a855-e2372e145f42%40googlegroups.com.

Reply via email to