Skip to content

_nth_root_naive fails for integer mod #32084

@kliem

Description

@kliem
sage -t --long --random-seed=3 src/sage/rings/finite_rings/integer_mod.pyx
**********************************************************************
File "src/sage/rings/finite_rings/integer_mod.pyx", line 1525, in sage.rings.finite_rings.integer_mod.IntegerMod_abstract._nth_root_naive
Failed example:
    for n in range(2,100): # long time
        K = Integers(n)
        elist = list(range(1,min(2*n+2,100)))
        for e in random_sublist(elist, 5/len(elist)):
            for a in random_sublist(range(1,n), min((n+2)//2,10)/(n-1)):
                b = K(a)
                try:
                    L = b.nth_root(e, all=True)
                    if L:
                        c = b.nth_root(e)
                except Exception:
                    L = [-1]
                M = b._nth_root_naive(e)
                if sorted(L) != M:
                    print("mod(%s, %s).nth_root(%s,all=True), mod(%s, %s)._nth_root_naive(%s)" % (a,n,e,a,n,e))
                if L and (c not in L):
                    print("mod(%s, %s).nth_root(%s), mod(%s, %s).nth_root(%s,all=True)" % (a,n,e,a,n,e))
Expected nothing
Got:
    mod(43, 75).nth_root(75), mod(43, 75).nth_root(75,all=True)

Component: algebra

Keywords: ring, mod, root

Author: Dave Morris

Branch/Commit: 226fe84

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/32084

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions