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 > <sage-...@googlegroups.com> 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.<q> = 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.<q> = 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.