(f, K, irreducible=False)
return False
Efficiently test if ``f`` is a cyclotomic polnomial.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x = ring("x", ZZ)

    >>> f = x**16 + x**14 - x**10 + x**8 - x**6 + x**2 + 1
    >>> R.dup_cyclotomic_p(f)
    False

    >>> g = x**16 + x**14 - x**10 - x**8 - x**6 + x**2 + 1
    >>> R.dup_cyclotomic_p(g)
    True
Efficiently test if ``f`` is a cyclotomic polnomial.
Efficiently test if f is a cyclotomic polnomial .
def dup_cyclotomic_p(f, K, irreducible=False):
    """
    Efficiently test if ``f`` is a cyclotomic polnomial.

    Examples
    ========

    >>> from sympy.polys import ring, ZZ
    >>> R, x = ring("x", ZZ)

    >>> f = x**16 + x**14 - x**10 + x**8 - x**6 + x**2 + 1
    >>> R.dup_cyclotomic_p(f)
    False

    >>> g = x**16 + x**14 - x**10 - x**8 - x**6 + x**2 + 1
    >>> R.dup_cyclotomic_p(g)
    True

    """
    if K.is_QQ:
        try:
            K0, K = K, K.get_ring()
            f = dup_convert(f, K0, K)
        except CoercionFailed:
            return False
    elif not K.is_ZZ:
        return False

    lc = dup_LC(f, K)
    tc = dup_TC(f, K)

    if lc != 1 or (tc != -1 and tc != 1):
        return False

    if not irreducible:
        coeff, factors = dup_factor_list(f, K)

        if coeff != K.one or factors != [(f, 1)]:
            return False

    n = dup_degree(f)
    g, h = [], []

    for i in xrange(n, -1, -2):
        g.insert(0, f[i])

    for i in xrange(n - 1, -1, -2):
        h.insert(0, f[i])

    g = dup_sqr(dup_strip(g), K)
    h = dup_sqr(dup_strip(h), K)

    F = dup_sub(g, dup_lshift(h, 1, K), K)

    if K.is_negative(dup_LC(F, K)):
        F = dup_neg(F, K)

    if F == f:
        return True

    g = dup_mirror(f, K)

    if K.is_negative(dup_LC(g, K)):
        g = dup_neg(g, K)

    if F == g and dup_cyclotomic_p(g, K):
        return True

    G = dup_sqf_part(F, K)

    if dup_sqr(G, K) == F and dup_cyclotomic_p(G, K):
        return True

    return False
def dup_cyclotomic_p ( f , K , irreducible = False ) : if K . is_QQ : try : K0 , K = K , K . get_ring ( ) f = dup_convert ( f , K0 , K ) except CoercionFailed : return False elif not K . is_ZZ : return False lc = dup_LC ( f , K ) tc = dup_TC ( f , K ) if lc != 1 or ( tc != - 1 and tc != 1 ) : return False if not irreducible : coeff , factors = dup_factor_list ( f , K ) if coeff != K . one or factors != [ ( f , 1 ) ] : return False n = dup_degree ( f ) g , h = [ ] , [ ] for i in xrange ( n , - 1 , - 2 ) : g . insert ( 0 , f [ i ] ) for i in xrange ( n - 1 , - 1 , - 2 ) : h . insert ( 0 , f [ i ] ) g = dup_sqr ( dup_strip ( g ) , K ) h = dup_sqr ( dup_strip ( h ) , K ) F = dup_sub ( g , dup_lshift ( h , 1 , K ) , K ) if K . is_negative ( dup_LC ( F , K ) ) : F = dup_neg ( F , K ) if F == f : return True g = dup_mirror ( f , K ) if K . is_negative ( dup_LC ( g , K ) ) : g = dup_neg ( g , K ) if F == g and dup_cyclotomic_p ( g , K ) : return True G = dup_sqf_part ( F , K ) if dup_sqr ( G , K ) == F and dup_cyclotomic_p ( G , K ) : return True return False