Re: [sage-devel] not easily reproducible QQbar bug

2022-01-13 Thread Vincent Delecroix

I am not able to reproduce. I ran 1000 times the same code snippet
you provided on all the sage that I have around me. Do you have the
bug in a fresh session  or after some hours of other unrelated
computations? In the first case, you can try to reproduce with

1. In an instance where you have the bug (at the start of a
   fresh session), get the initial random seed with initial_seed()

2. Start a fresh session, set the initial seed with
   set_random_seed(value_from_point_1_above) and rerun
   the code snippet

Best
Vincent

Le 13/01/2022 à 15:16, 'Martin R' via sage-devel a écrit :

ubuntu 21.04
'SageMath version 9.5.beta7, Release Date: 2021-11-18'

On Thursday, 13 January 2022 at 15:09:57 UTC+1 vdelecroix wrote:


Could you be more specific : Which sage version ? which setup ?

Vincent

Le 13/01/2022 à 15:05, 'Martin R' via sage-devel a écrit :

I have some very strange behaviour of a substitution, which I don't know
how to reproduce, but it happens from time to time, and is REALLY
disturbing. I don't even know what to write into a ticket, so I'm asking
here first. The definition of CSP is at the end of the mail.

sage: R. = ZZ[]
sage: p = q^21 + q^20 + q^19 + q^18 + q^17 + q^16 + q^15 + q^14 + q^13 +
q^12 + q^11 + 2*q^10 + 2*q^9 + 2*q^8 + 2*q^7 + 2*q^6 + 2*q^5 + 2*q^4 +
2*q^3 + 2*q^2 + 3*q + 4
sage: p == CSP(22)
True
sage: CSP(22).subs({q:QQbar.zeta(2)})
-28
sage: CSP(22).subs({q:QQbar.zeta(2)})
2
sage: CSP(22).parent()
Univariate Polynomial Ring in q over Integer Ring

Sometimes I also get a complex number.

Martin

###
def cycle_power(g, e):
"""
Return k such that g^k = e
"""
if e.is_one():
return 0
k = 1
p = g
while True:
if e == p:
return k
p *= g
k += 1

@cached_function
def CSP(n):
C = groups.permutation.Cyclic(n)
g = C.gen()
R. = ZZ[]
return sum(q^min(cycle_power(g, e) for e in coset) for H in
C.subgroups() for coset in C.cosets(H))







--
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 sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/57c62fad-c645-9883-50c5-3605cb557b5a%40gmail.com.


Re: [sage-devel] not easily reproducible QQbar bug

2022-01-13 Thread 'Martin R' via sage-devel
I agree to all of your 3 points :-)

On Thursday, 13 January 2022 at 15:34:02 UTC+1 john.c...@gmail.com wrote:

> On Thu, 13 Jan 2022 at 14:05, 'Martin R' via sage-devel
>  wrote:
> >
> > I have some very strange behaviour of a substitution, which I don't know 
> how to reproduce, but it happens from time to time, and is REALLY 
> disturbing. I don't even know what to write into a ticket, so I'm asking 
> here first. The definition of CSP is at the end of the mail.
> >
> > sage: R. = ZZ[]
> > sage: p = q^21 + q^20 + q^19 + q^18 + q^17 + q^16 + q^15 + q^14 + q^13 + 
> q^12 + q^11 + 2*q^10 + 2*q^9 + 2*q^8 + 2*q^7 + 2*q^6 + 2*q^5 + 2*q^4 + 
> 2*q^3 + 2*q^2 + 3*q + 4
> > sage: p == CSP(22)
> > True
> > sage: CSP(22).subs({q:QQbar.zeta(2)})
> > -28
> > sage: CSP(22).subs({q:QQbar.zeta(2)})
> > 2
> > sage: CSP(22).parent()
> > Univariate Polynomial Ring in q over Integer Ring
> >
> > Sometimes I also get a complex number.
> >
> > Martin
> >
> > ###
> > def cycle_power(g, e):
> > """
> > Return k such that g^k = e
> > """
> > if e.is_one():
> > return 0
> > k = 1
> > p = g
> > while True:
> > if e == p:
> > return k
> > p *= g
> > k += 1
> >
>
> 1. You could be using discrete_log() or one of its variants instead of
> your cycle_power() function.
>
> 2. In CSP() would it not be faster to work out for each power h=g^k,
> how many times h will arise and hence the coefficient of q^k? The
> pattern in your example is fairly simple to see.
>
> I know that neither of these points answers your actual question...
>
> John
>
> > @cached_function
> > def CSP(n):
> > C = groups.permutation.Cyclic(n)
> > g = C.gen()
> > R. = ZZ[]
> > return sum(q^min(cycle_power(g, e) for e in coset) for H in 
> C.subgroups() for coset in C.cosets(H))
> >
> > --
> > 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 sage-devel+...@googlegroups.com.
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-devel/a013e022-a007-4748-9a67-ae1e45f3e825n%40googlegroups.com
> .
>

-- 
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 sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/737a4ead-3067-4387-a489-60b025e37ed3n%40googlegroups.com.


Re: [sage-devel] not easily reproducible QQbar bug

2022-01-13 Thread John Cremona
On Thu, 13 Jan 2022 at 14:05, 'Martin R' via sage-devel
 wrote:
>
> I have some very strange behaviour of a substitution, which I don't know how 
> to reproduce, but it happens from time to time, and is REALLY disturbing.  I 
> don't even know what to write into a ticket, so I'm asking here first.  The 
> definition of CSP is at the end of the mail.
>
> sage: R. = ZZ[]
> sage: p = q^21 + q^20 + q^19 + q^18 + q^17 + q^16 + q^15 + q^14 + q^13 + q^12 
> + q^11 + 2*q^10 + 2*q^9 + 2*q^8 + 2*q^7 + 2*q^6 + 2*q^5 + 2*q^4 + 2*q^3 + 
> 2*q^2 + 3*q + 4
> sage: p == CSP(22)
> True
> sage: CSP(22).subs({q:QQbar.zeta(2)})
> -28
> sage: CSP(22).subs({q:QQbar.zeta(2)})
> 2
> sage: CSP(22).parent()
> Univariate Polynomial Ring in q over Integer Ring
>
> Sometimes I also get a complex number.
>
> Martin
>
> ###
> def cycle_power(g, e):
> """
> Return k such that g^k = e
> """
> if e.is_one():
> return 0
> k = 1
> p = g
> while True:
> if e == p:
> return k
> p *= g
> k += 1
>

1. You could be using discrete_log() or one of its variants instead of
your cycle_power() function.

2. In CSP() would it not be faster to work out for each power h=g^k,
how many times h will arise and hence the coefficient of q^k?  The
pattern in your example is fairly simple to see.

I know that neither of these points answers your actual question...

John

> @cached_function
> def CSP(n):
> C = groups.permutation.Cyclic(n)
> g = C.gen()
> R. = ZZ[]
> return sum(q^min(cycle_power(g, e) for e in coset) for H in C.subgroups() 
> for coset in C.cosets(H))
>
> --
> 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 sage-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-devel/a013e022-a007-4748-9a67-ae1e45f3e825n%40googlegroups.com.

-- 
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 sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/CAD0p0K6wEu9pL%2BeOU8FG3PyP7Twgarq-6w-NPNoNZDdMJOmpSw%40mail.gmail.com.


Re: [sage-devel] not easily reproducible QQbar bug

2022-01-13 Thread 'Martin R' via sage-devel
ubuntu 21.04
'SageMath version 9.5.beta7, Release Date: 2021-11-18'

On Thursday, 13 January 2022 at 15:09:57 UTC+1 vdelecroix wrote:

> Could you be more specific : Which sage version ? which setup ?
>
> Vincent
>
> Le 13/01/2022 à 15:05, 'Martin R' via sage-devel a écrit :
> > I have some very strange behaviour of a substitution, which I don't know
> > how to reproduce, but it happens from time to time, and is REALLY
> > disturbing. I don't even know what to write into a ticket, so I'm asking
> > here first. The definition of CSP is at the end of the mail.
> > 
> > sage: R. = ZZ[]
> > sage: p = q^21 + q^20 + q^19 + q^18 + q^17 + q^16 + q^15 + q^14 + q^13 +
> > q^12 + q^11 + 2*q^10 + 2*q^9 + 2*q^8 + 2*q^7 + 2*q^6 + 2*q^5 + 2*q^4 +
> > 2*q^3 + 2*q^2 + 3*q + 4
> > sage: p == CSP(22)
> > True
> > sage: CSP(22).subs({q:QQbar.zeta(2)})
> > -28
> > sage: CSP(22).subs({q:QQbar.zeta(2)})
> > 2
> > sage: CSP(22).parent()
> > Univariate Polynomial Ring in q over Integer Ring
> > 
> > Sometimes I also get a complex number.
> > 
> > Martin
> > 
> > ###
> > def cycle_power(g, e):
> > """
> > Return k such that g^k = e
> > """
> > if e.is_one():
> > return 0
> > k = 1
> > p = g
> > while True:
> > if e == p:
> > return k
> > p *= g
> > k += 1
> > 
> > @cached_function
> > def CSP(n):
> > C = groups.permutation.Cyclic(n)
> > g = C.gen()
> > R. = ZZ[]
> > return sum(q^min(cycle_power(g, e) for e in coset) for H in
> > C.subgroups() for coset in C.cosets(H))
> > 
>

-- 
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 sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/7666fd06-2e97-4bed-923c-407bf1299395n%40googlegroups.com.


Re: [sage-devel] not easily reproducible QQbar bug

2022-01-13 Thread Vincent Delecroix

Could you be more specific : Which sage version ? which setup ?

Vincent

Le 13/01/2022 à 15:05, 'Martin R' via sage-devel a écrit :

I have some very strange behaviour of a substitution, which I don't know
how to reproduce, but it happens from time to time, and is REALLY
disturbing.  I don't even know what to write into a ticket, so I'm asking
here first.  The definition of CSP is at the end of the mail.

sage: R. = ZZ[]
sage: p = q^21 + q^20 + q^19 + q^18 + q^17 + q^16 + q^15 + q^14 + q^13 +
q^12 + q^11 + 2*q^10 + 2*q^9 + 2*q^8 + 2*q^7 + 2*q^6 + 2*q^5 + 2*q^4 +
2*q^3 + 2*q^2 + 3*q + 4
sage: p == CSP(22)
True
sage: CSP(22).subs({q:QQbar.zeta(2)})
-28
sage: CSP(22).subs({q:QQbar.zeta(2)})
2
sage: CSP(22).parent()
Univariate Polynomial Ring in q over Integer Ring

Sometimes I also get a complex number.

Martin

###
def cycle_power(g, e):
 """
 Return k such that g^k = e
 """
 if e.is_one():
 return 0
 k = 1
 p = g
 while True:
 if e == p:
 return k
 p *= g
 k += 1

@cached_function
def CSP(n):
 C = groups.permutation.Cyclic(n)
 g = C.gen()
 R. = ZZ[]
 return sum(q^min(cycle_power(g, e) for e in coset) for H in
C.subgroups() for coset in C.cosets(H))



--
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 sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/a05289f9-3b44-b4fa-e119-3c8b07c54a39%40gmail.com.


[sage-devel] not easily reproducible QQbar bug

2022-01-13 Thread 'Martin R' via sage-devel
I have some very strange behaviour of a substitution, which I don't know 
how to reproduce, but it happens from time to time, and is REALLY 
disturbing.  I don't even know what to write into a ticket, so I'm asking 
here first.  The definition of CSP is at the end of the mail.

sage: R. = ZZ[]
sage: p = q^21 + q^20 + q^19 + q^18 + q^17 + q^16 + q^15 + q^14 + q^13 + 
q^12 + q^11 + 2*q^10 + 2*q^9 + 2*q^8 + 2*q^7 + 2*q^6 + 2*q^5 + 2*q^4 + 
2*q^3 + 2*q^2 + 3*q + 4
sage: p == CSP(22)
True
sage: CSP(22).subs({q:QQbar.zeta(2)})
-28
sage: CSP(22).subs({q:QQbar.zeta(2)})
2
sage: CSP(22).parent()
Univariate Polynomial Ring in q over Integer Ring

Sometimes I also get a complex number.

Martin

###
def cycle_power(g, e):
"""
Return k such that g^k = e
"""
if e.is_one():
return 0
k = 1
p = g
while True:
if e == p:
return k
p *= g
k += 1

@cached_function
def CSP(n):
C = groups.permutation.Cyclic(n)
g = C.gen()
R. = ZZ[]
return sum(q^min(cycle_power(g, e) for e in coset) for H in 
C.subgroups() for coset in C.cosets(H))

-- 
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 sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/a013e022-a007-4748-9a67-ae1e45f3e825n%40googlegroups.com.