def _minpoly_cos(ex, x):
    '\n    Returns the minimal polynomial of ``cos(ex)``\n    see https://mathworld.wolfram.com/TrigonometryAngles.html\n\n    '
    (c, a) = ex.args[0].as_coeff_Mul()
    if (a is pi):
        if (c.numerator == 1):
            if (c.denominator == 7):
                return ((((8 * (x ** 3)) - (4 * (x ** 2))) - (4 * x)) + 1)
            elif (c.denominator == 9):
                return (((8 * (x ** 3)) - (6 * x)) - 1)
        elif (c.numerator == 2):
            q = sympify(c.denominator)
            if q.is_prime:
                s = _minpoly_sin(ex, x)
                return _mexpand(s.subs({x: sqrt(((1 - x) / 2))}))
        n = int(c.denominator)
        a = chebyshevt_poly(n, polys=True).all_coeffs()
        a = [((x ** (n - i)) * a[(n - i)]) for i in range((n + 1))]
        r = (Add(*a) - ((- 1) ** c.numerator))
        (_, factors) = factor_list(r)
        return _choose_factor(factors, x, ex)
    raise NotAlgebraic(f"{ex} doesn't seem to be an algebraic element")
Returns the minimal polynomial of ``cos(ex)``
see https://mathworld.wolfram.com/TrigonometryAngles.html
def _minpoly_cos(ex, x):
    '\n    Returns the minimal polynomial of ``cos(ex)``\n    see https://mathworld.wolfram.com/TrigonometryAngles.html\n\n    '
    (c, a) = ex.args[0].as_coeff_Mul()
    if (a is pi):
        if (c.numerator == 1):
            if (c.denominator == 7):
                return ((((8 * (x ** 3)) - (4 * (x ** 2))) - (4 * x)) + 1)
            elif (c.denominator == 9):
                return (((8 * (x ** 3)) - (6 * x)) - 1)
        elif (c.numerator == 2):
            q = sympify(c.denominator)
            if q.is_prime:
                s = _minpoly_sin(ex, x)
                return _mexpand(s.subs({x: sqrt(((1 - x) / 2))}))
        n = int(c.denominator)
        a = chebyshevt_poly(n, polys=True).all_coeffs()
        a = [((x ** (n - i)) * a[(n - i)]) for i in range((n + 1))]
        r = (Add(*a) - ((- 1) ** c.numerator))
        (_, factors) = factor_list(r)
        return _choose_factor(factors, x, ex)
    raise NotAlgebraic(f"{ex} doesn't seem to be an algebraic element")