<s> """<STR_LIT>""" <EOL> from sympy import ( S , Rational , Symbol , Poly , sqrt , I , oo , Tuple , expand , <EOL> pi , cos , sin , exp ) <EOL> from sympy . utilities . pytest import raises , slow <EOL> from sympy . core . compatibility import range <EOL> from sympy . polys . numberfields import ( <EOL> minimal_polynomial , <EOL> primitive_element , <EOL> is_isomorphism_possible , <EOL> field_isomorphism_pslq , <EOL> field_isomorphism , <EOL> to_number_field , <EOL> AlgebraicNumber , <EOL> isolate , IntervalPrinter , <EOL> ) <EOL> from sympy . polys . polyerrors import ( <EOL> IsomorphismFailed , <EOL> NotAlgebraic , <EOL> GeneratorsError , <EOL> ) <EOL> from sympy . polys . polyclasses import DMP <EOL> from sympy . polys . domains import QQ <EOL> from sympy . polys . rootoftools import rootof <EOL> from sympy . polys . polytools import degree <EOL> from sympy . abc import x , y , z <EOL> Q = Rational <EOL> def test_minimal_polynomial ( ) : <EOL> assert minimal_polynomial ( - <NUM_LIT:7> , x ) == x + <NUM_LIT:7> <EOL> assert minimal_polynomial ( - <NUM_LIT:1> , x ) == x + <NUM_LIT:1> <EOL> assert minimal_polynomial ( <NUM_LIT:0> , x ) == x <EOL> assert minimal_polynomial ( <NUM_LIT:1> , x ) == x - <NUM_LIT:1> <EOL> assert minimal_polynomial ( <NUM_LIT:7> , x ) == x - <NUM_LIT:7> <EOL> assert minimal_polynomial ( sqrt ( <NUM_LIT:2> ) , x ) == x ** <NUM_LIT:2> - <NUM_LIT:2> <EOL> assert minimal_polynomial ( sqrt ( <NUM_LIT:5> ) , x ) == x ** <NUM_LIT:2> - <NUM_LIT:5> <EOL> assert minimal_polynomial ( sqrt ( <NUM_LIT:6> ) , x ) == x ** <NUM_LIT:2> - <NUM_LIT:6> <EOL> assert minimal_polynomial ( <NUM_LIT:2> * sqrt ( <NUM_LIT:2> ) , x ) == x ** <NUM_LIT:2> - <NUM_LIT:8> <EOL> assert minimal_polynomial ( <NUM_LIT:3> * sqrt ( <NUM_LIT:5> ) , x ) == x ** <NUM_LIT:2> - <NUM_LIT> <EOL> assert minimal_polynomial ( <NUM_LIT:4> * sqrt ( <NUM_LIT:6> ) , x ) == x ** <NUM_LIT:2> - <NUM_LIT> <EOL> assert minimal_polynomial ( <NUM_LIT:2> * sqrt ( <NUM_LIT:2> ) + <NUM_LIT:3> , x ) == x ** <NUM_LIT:2> - <NUM_LIT:6> * x + <NUM_LIT:1> <EOL> assert minimal_polynomial ( <NUM_LIT:3> * sqrt ( <NUM_LIT:5> ) + <NUM_LIT:6> , x ) == x ** <NUM_LIT:2> - <NUM_LIT:12> * x - <NUM_LIT:9> <EOL> assert minimal_polynomial ( <NUM_LIT:4> * sqrt ( <NUM_LIT:6> ) + <NUM_LIT:7> , x ) == x ** <NUM_LIT:2> - <NUM_LIT> * x - <NUM_LIT> <EOL> assert minimal_polynomial ( <NUM_LIT:2> * sqrt ( <NUM_LIT:2> ) - <NUM_LIT:3> , x ) == x ** <NUM_LIT:2> + <NUM_LIT:6> * x + <NUM_LIT:1> <EOL> assert minimal_polynomial ( <NUM_LIT:3> * sqrt ( <NUM_LIT:5> ) - <NUM_LIT:6> , x ) == x ** <NUM_LIT:2> + <NUM_LIT:12> * x - <NUM_LIT:9> <EOL> assert minimal_polynomial ( <NUM_LIT:4> * sqrt ( <NUM_LIT:6> ) - <NUM_LIT:7> , x ) == x ** <NUM_LIT:2> + <NUM_LIT> * x - <NUM_LIT> <EOL> assert minimal_polynomial ( sqrt ( <NUM_LIT:1> + sqrt ( <NUM_LIT:6> ) ) , x ) == x ** <NUM_LIT:4> - <NUM_LIT:2> * x ** <NUM_LIT:2> - <NUM_LIT:5> <EOL> assert minimal_polynomial ( sqrt ( I + sqrt ( <NUM_LIT:6> ) ) , x ) == x ** <NUM_LIT:8> - <NUM_LIT:10> * x ** <NUM_LIT:4> + <NUM_LIT> <EOL> assert minimal_polynomial ( <NUM_LIT:2> * I + sqrt ( <NUM_LIT:2> + I ) , x ) == x ** <NUM_LIT:4> + <NUM_LIT:4> * x ** <NUM_LIT:2> + <NUM_LIT:8> * x + <NUM_LIT> <EOL> assert minimal_polynomial ( sqrt ( <NUM_LIT:2> ) + sqrt ( <NUM_LIT:3> ) , x ) == x ** <NUM_LIT:4> - <NUM_LIT:10> * x ** <NUM_LIT:2> + <NUM_LIT:1> <EOL> assert minimal_polynomial ( <EOL> sqrt ( <NUM_LIT:2> ) + sqrt ( <NUM_LIT:3> ) + sqrt ( <NUM_LIT:6> ) , x ) == x ** <NUM_LIT:4> - <NUM_LIT> * x ** <NUM_LIT:2> - <NUM_LIT> * x - <NUM_LIT> <EOL> a = <NUM_LIT:1> - <NUM_LIT:9> * sqrt ( <NUM_LIT:2> ) + <NUM_LIT:7> * sqrt ( <NUM_LIT:3> ) <EOL> assert minimal_polynomial ( <EOL> <NUM_LIT:1> / a , x ) == <NUM_LIT> * x ** <NUM_LIT:4> - <NUM_LIT> * x ** <NUM_LIT:3> + <NUM_LIT> * x ** <NUM_LIT:2> + <NUM_LIT:4> * x - <NUM_LIT:1> <EOL> assert minimal_polynomial ( <EOL> <NUM_LIT:1> / sqrt ( a ) , x ) == <NUM_LIT> * x ** <NUM_LIT:8> - <NUM_LIT> * x ** <NUM_LIT:6> + <NUM_LIT> * x ** <NUM_LIT:4> + <NUM_LIT:4> * x ** <NUM_LIT:2> - <NUM_LIT:1> <EOL> raises ( NotAlgebraic , lambda : minimal_polynomial ( oo , x ) ) <EOL> raises ( NotAlgebraic , lambda : minimal_polynomial ( <NUM_LIT:2> ** y , x ) ) <EOL> raises ( NotAlgebraic , lambda : minimal_polynomial ( sin ( <NUM_LIT:1> ) , x ) ) <EOL> assert minimal_polynomial ( sqrt ( <NUM_LIT:2> ) ) . dummy_eq ( x ** <NUM_LIT:2> - <NUM_LIT:2> ) <EOL> assert minimal_polynomial ( sqrt ( <NUM_LIT:2> ) , x ) == x ** <NUM_LIT:2> - <NUM_LIT:2> <EOL> assert minimal_polynomial ( sqrt ( <NUM_LIT:2> ) , polys = True ) == Poly ( x ** <NUM_LIT:2> - <NUM_LIT:2> ) <EOL> assert minimal_polynomial ( sqrt ( <NUM_LIT:2> ) , x , polys = True ) == Poly ( x ** <NUM_LIT:2> - <NUM_LIT:2> ) <EOL> assert minimal_polynomial ( sqrt ( <NUM_LIT:2> ) , x , polys = True , compose = False ) == Poly ( x ** <NUM_LIT:2> - <NUM_LIT:2> ) <EOL> a = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) ) <EOL> b = AlgebraicNumber ( sqrt ( <NUM_LIT:3> ) ) <EOL> assert minimal_polynomial ( a , x ) == x ** <NUM_LIT:2> - <NUM_LIT:2> <EOL> assert minimal_polynomial ( b , x ) == x ** <NUM_LIT:2> - <NUM_LIT:3> <EOL> assert minimal_polynomial ( a , x , polys = True ) == Poly ( x ** <NUM_LIT:2> - <NUM_LIT:2> ) <EOL> assert minimal_polynomial ( b , x , polys = True ) == Poly ( x ** <NUM_LIT:2> - <NUM_LIT:3> ) <EOL> assert minimal_polynomial ( sqrt ( a / <NUM_LIT:2> + <NUM_LIT> ) , x ) == <NUM_LIT:2> * x ** <NUM_LIT:4> - <NUM_LIT> * x ** <NUM_LIT:2> + <NUM_LIT> <EOL> assert minimal_polynomial ( sqrt ( b / <NUM_LIT:2> + <NUM_LIT> ) , x ) == <NUM_LIT:4> * x ** <NUM_LIT:4> - <NUM_LIT> * x ** <NUM_LIT:2> + <NUM_LIT> <EOL> a , b = sqrt ( <NUM_LIT:2> ) / <NUM_LIT:3> + <NUM_LIT:7> , AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) / <NUM_LIT:3> + <NUM_LIT:7> ) <EOL> f = <NUM_LIT> * x ** <NUM_LIT:8> - <NUM_LIT> * x ** <NUM_LIT:6> - <NUM_LIT> * x ** <NUM_LIT:5> + <NUM_LIT> * x ** <NUM_LIT:4> + <NUM_LIT> * x ** <NUM_LIT:3> - <NUM_LIT> * x ** <NUM_LIT:2> - <NUM_LIT> * x + <NUM_LIT> <EOL> assert minimal_polynomial ( sqrt ( a ) + sqrt ( sqrt ( a ) ) , x ) == f <EOL> assert minimal_polynomial ( sqrt ( b ) + sqrt ( sqrt ( b ) ) , x ) == f <EOL> assert minimal_polynomial ( <EOL> a ** Q ( <NUM_LIT:3> , <NUM_LIT:2> ) , x ) == <NUM_LIT> * x ** <NUM_LIT:4> - <NUM_LIT> * x ** <NUM_LIT:2> + <NUM_LIT> <EOL> eq = S ( '''<STR_LIT>''' ) <EOL> assert minimal_polynomial ( eq , x ) == <NUM_LIT> * x ** <NUM_LIT:2> - <NUM_LIT:1> <EOL> ex = <NUM_LIT:1> + sqrt ( <NUM_LIT:2> ) + sqrt ( <NUM_LIT:3> ) <EOL> mp = minimal_polynomial ( ex , x ) <EOL> assert mp == x ** <NUM_LIT:4> - <NUM_LIT:4> * x ** <NUM_LIT:3> - <NUM_LIT:4> * x ** <NUM_LIT:2> + <NUM_LIT:16> * x - <NUM_LIT:8> <EOL> ex = <NUM_LIT:1> / ( <NUM_LIT:1> + sqrt ( <NUM_LIT:2> ) + sqrt ( <NUM_LIT:3> ) ) <EOL> mp = minimal_polynomial ( ex , x ) <EOL> assert mp == <NUM_LIT:8> * x ** <NUM_LIT:4> - <NUM_LIT:16> * x ** <NUM_LIT:3> + <NUM_LIT:4> * x ** <NUM_LIT:2> + <NUM_LIT:4> * x - <NUM_LIT:1> <EOL> p = ( expand ( ( <NUM_LIT:1> + sqrt ( <NUM_LIT:2> ) - <NUM_LIT:2> * sqrt ( <NUM_LIT:3> ) + sqrt ( <NUM_LIT:7> ) ) ** <NUM_LIT:3> ) ) ** Rational ( <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> mp = minimal_polynomial ( p , x ) <EOL> assert mp == x ** <NUM_LIT:8> - <NUM_LIT:8> * x ** <NUM_LIT:7> - <NUM_LIT> * x ** <NUM_LIT:6> + <NUM_LIT> * x ** <NUM_LIT:5> + <NUM_LIT> * x ** <NUM_LIT:4> - <NUM_LIT> * x ** <NUM_LIT:3> + <NUM_LIT> * x ** <NUM_LIT:2> + <NUM_LIT> * x - <NUM_LIT> <EOL> p = expand ( ( <NUM_LIT:1> + sqrt ( <NUM_LIT:2> ) - <NUM_LIT:2> * sqrt ( <NUM_LIT:3> ) + sqrt ( <NUM_LIT:7> ) ) ** <NUM_LIT:3> ) <EOL> mp = minimal_polynomial ( p , x ) <EOL> assert mp == x ** <NUM_LIT:8> - <NUM_LIT> * x ** <NUM_LIT:7> - <NUM_LIT> * x ** <NUM_LIT:6> + <NUM_LIT> * x ** <NUM_LIT:5> + <NUM_LIT> * x ** <NUM_LIT:4> - <NUM_LIT> * x ** <NUM_LIT:3> + <NUM_LIT> * x ** <NUM_LIT:2> + <NUM_LIT> * x - <NUM_LIT> <EOL> assert minimal_polynomial ( S ( "<STR_LIT>" ) , x ) == x - <NUM_LIT:1> <EOL> a = <NUM_LIT:1> + sqrt ( <NUM_LIT:2> ) <EOL> assert minimal_polynomial ( ( a * sqrt ( <NUM_LIT:2> ) + a ) ** <NUM_LIT:3> , x ) == x ** <NUM_LIT:2> - <NUM_LIT> * x + <NUM_LIT:1> <EOL> p = <NUM_LIT:1> / ( <NUM_LIT:1> + sqrt ( <NUM_LIT:2> ) + sqrt ( <NUM_LIT:3> ) ) <EOL> assert minimal_polynomial ( p , x , compose = False ) == <NUM_LIT:8> * x ** <NUM_LIT:4> - <NUM_LIT:16> * x ** <NUM_LIT:3> + <NUM_LIT:4> * x ** <NUM_LIT:2> + <NUM_LIT:4> * x - <NUM_LIT:1> <EOL> p = <NUM_LIT:2> / ( <NUM_LIT:1> + sqrt ( <NUM_LIT:2> ) + sqrt ( <NUM_LIT:3> ) ) <EOL> assert minimal_polynomial ( p , x , compose = False ) == x ** <NUM_LIT:4> - <NUM_LIT:4> * x ** <NUM_LIT:3> + <NUM_LIT:2> * x ** <NUM_LIT:2> + <NUM_LIT:4> * x - <NUM_LIT:2> <EOL> assert minimal_polynomial ( <NUM_LIT:1> + sqrt ( <NUM_LIT:2> ) * I , x , compose = False ) == x ** <NUM_LIT:2> - <NUM_LIT:2> * x + <NUM_LIT:3> <EOL> assert minimal_polynomial ( <NUM_LIT:1> / ( <NUM_LIT:1> + sqrt ( <NUM_LIT:2> ) ) + <NUM_LIT:1> , x , compose = False ) == x ** <NUM_LIT:2> - <NUM_LIT:2> <EOL> assert minimal_polynomial ( sqrt ( <NUM_LIT:2> ) * I + I * ( <NUM_LIT:1> + sqrt ( <NUM_LIT:2> ) ) , x , <EOL> compose = False ) == x ** <NUM_LIT:4> + <NUM_LIT> * x ** <NUM_LIT:2> + <NUM_LIT> <EOL> def test_minimal_polynomial_hi_prec ( ) : <EOL> p = <NUM_LIT:1> / sqrt ( <NUM_LIT:1> - <NUM_LIT:9> * sqrt ( <NUM_LIT:2> ) + <NUM_LIT:7> * sqrt ( <NUM_LIT:3> ) + S ( <NUM_LIT:1> ) / <NUM_LIT:10> ** <NUM_LIT:30> ) <EOL> mp = minimal_polynomial ( p , x ) <EOL> assert mp . coeff ( x ** <NUM_LIT:6> ) == - <NUM_LIT> <EOL> def test_minimal_polynomial_sq ( ) : <EOL> from sympy import Add , expand_multinomial <EOL> p = expand_multinomial ( ( <NUM_LIT:1> + <NUM_LIT:5> * sqrt ( <NUM_LIT:2> ) + <NUM_LIT:2> * sqrt ( <NUM_LIT:3> ) ) ** <NUM_LIT:3> ) <EOL> mp = minimal_polynomial ( p ** Rational ( <NUM_LIT:1> , <NUM_LIT:3> ) , x ) <EOL> assert mp == x ** <NUM_LIT:4> - <NUM_LIT:4> * x ** <NUM_LIT:3> - <NUM_LIT> * x ** <NUM_LIT:2> + <NUM_LIT> * x + <NUM_LIT> <EOL> p = expand_multinomial ( ( <NUM_LIT:1> + sqrt ( <NUM_LIT:2> ) - <NUM_LIT:2> * sqrt ( <NUM_LIT:3> ) + sqrt ( <NUM_LIT:7> ) ) ** <NUM_LIT:3> ) <EOL> mp = minimal_polynomial ( p ** Rational ( <NUM_LIT:1> , <NUM_LIT:3> ) , x ) <EOL> assert mp == x ** <NUM_LIT:8> - <NUM_LIT:8> * x ** <NUM_LIT:7> - <NUM_LIT> * x ** <NUM_LIT:6> + <NUM_LIT> * x ** <NUM_LIT:5> + <NUM_LIT> * x ** <NUM_LIT:4> - <NUM_LIT> * x ** <NUM_LIT:3> + <NUM_LIT> * x ** <NUM_LIT:2> + <NUM_LIT> * x - <NUM_LIT> <EOL> p = Add ( * [ sqrt ( i ) for i in range ( <NUM_LIT:1> , <NUM_LIT:12> ) ] ) <EOL> mp = minimal_polynomial ( p , x ) <EOL> assert mp . subs ( { x : <NUM_LIT:0> } ) == - <NUM_LIT> <EOL> def test_minpoly_compose ( ) : <EOL> eq = S ( '''<STR_LIT>''' ) <EOL> mp = minimal_polynomial ( eq + <NUM_LIT:3> , x ) <EOL> assert mp == <NUM_LIT> * x ** <NUM_LIT:2> - <NUM_LIT> * x + <NUM_LIT> <EOL> assert minimal_polynomial ( exp ( I * pi / <NUM_LIT:8> ) , x ) == x ** <NUM_LIT:8> + <NUM_LIT:1> <EOL> mp = minimal_polynomial ( sin ( pi / <NUM_LIT:7> ) + sqrt ( <NUM_LIT:2> ) , x ) <EOL> assert mp == <NUM_LIT> * x ** <NUM_LIT:12> - <NUM_LIT> * x ** <NUM_LIT:10> + <NUM_LIT> * x ** <NUM_LIT:8> - <NUM_LIT> * x ** <NUM_LIT:6> + <NUM_LIT> * x ** <NUM_LIT:4> - <NUM_LIT> * x ** <NUM_LIT:2> + <NUM_LIT> <EOL> mp = minimal_polynomial ( cos ( pi / <NUM_LIT:7> ) + sqrt ( <NUM_LIT:2> ) , x ) <EOL> assert mp == <NUM_LIT:64> * x ** <NUM_LIT:6> - <NUM_LIT:64> * x ** <NUM_LIT:5> - <NUM_LIT> * x ** <NUM_LIT:4> + <NUM_LIT> * x ** <NUM_LIT:3> + <NUM_LIT> * x ** <NUM_LIT:2> - <NUM_LIT> * x - <NUM_LIT> <EOL> mp = minimal_polynomial ( exp ( I * pi / <NUM_LIT:7> ) + sqrt ( <NUM_LIT:2> ) , x ) <EOL> assert mp == x ** <NUM_LIT:12> - <NUM_LIT:2> * x ** <NUM_LIT:11> - <NUM_LIT:9> * x ** <NUM_LIT:10> + <NUM_LIT:16> * x ** <NUM_LIT:9> + <NUM_LIT> * x ** <NUM_LIT:8> - <NUM_LIT> * x ** <NUM_LIT:7> - <NUM_LIT> * x ** <NUM_LIT:6> + <NUM_LIT> * x ** <NUM_LIT:5> + <NUM_LIT> * x ** <NUM_LIT:4> - <NUM_LIT> * x ** <NUM_LIT:3> - <NUM_LIT> * x ** <NUM_LIT:2> + <NUM_LIT> * x + <NUM_LIT> <EOL> mp = minimal_polynomial ( sin ( pi / <NUM_LIT:7> ) + sqrt ( <NUM_LIT:2> ) , x ) <EOL> assert mp == <NUM_LIT> * x ** <NUM_LIT:12> - <NUM_LIT> * x ** <NUM_LIT:10> + <NUM_LIT> * x ** <NUM_LIT:8> - <NUM_LIT> * x ** <NUM_LIT:6> + <NUM_LIT> * x ** <NUM_LIT:4> - <NUM_LIT> * x ** <NUM_LIT:2> + <NUM_LIT> <EOL> mp = minimal_polynomial ( cos ( pi / <NUM_LIT:7> ) + sqrt ( <NUM_LIT:2> ) , x ) <EOL> assert mp == <NUM_LIT:64> * x ** <NUM_LIT:6> - <NUM_LIT:64> * x ** <NUM_LIT:5> - <NUM_LIT> * x ** <NUM_LIT:4> + <NUM_LIT> * x ** <NUM_LIT:3> + <NUM_LIT> * x ** <NUM_LIT:2> - <NUM_LIT> * x - <NUM_LIT> <EOL> mp = minimal_polynomial ( exp ( I * pi / <NUM_LIT:7> ) + sqrt ( <NUM_LIT:2> ) , x ) <EOL> assert mp == x ** <NUM_LIT:12> - <NUM_LIT:2> * x ** <NUM_LIT:11> - <NUM_LIT:9> * x ** <NUM_LIT:10> + <NUM_LIT:16> * x ** <NUM_LIT:9> + <NUM_LIT> * x ** <NUM_LIT:8> - <NUM_LIT> * x ** <NUM_LIT:7> - <NUM_LIT> * x ** <NUM_LIT:6> + <NUM_LIT> * x ** <NUM_LIT:5> + <NUM_LIT> * x ** <NUM_LIT:4> - <NUM_LIT> * x ** <NUM_LIT:3> - <NUM_LIT> * x ** <NUM_LIT:2> + <NUM_LIT> * x + <NUM_LIT> <EOL> mp = minimal_polynomial ( exp ( <NUM_LIT:2> * I * pi / <NUM_LIT:7> ) , x ) <EOL> assert mp == x ** <NUM_LIT:6> + x ** <NUM_LIT:5> + x ** <NUM_LIT:4> + x ** <NUM_LIT:3> + x ** <NUM_LIT:2> + x + <NUM_LIT:1> <EOL> mp = minimal_polynomial ( exp ( <NUM_LIT:2> * I * pi / <NUM_LIT:15> ) , x ) <EOL> assert mp == x ** <NUM_LIT:8> - x ** <NUM_LIT:7> + x ** <NUM_LIT:5> - x ** <NUM_LIT:4> + x ** <NUM_LIT:3> - x + <NUM_LIT:1> <EOL> mp = minimal_polynomial ( cos ( <NUM_LIT:2> * pi / <NUM_LIT:7> ) , x ) <EOL> assert mp == <NUM_LIT:8> * x ** <NUM_LIT:3> + <NUM_LIT:4> * x ** <NUM_LIT:2> - <NUM_LIT:4> * x - <NUM_LIT:1> <EOL> mp = minimal_polynomial ( sin ( <NUM_LIT:2> * pi / <NUM_LIT:7> ) , x ) <EOL> ex = ( <NUM_LIT:5> * cos ( <NUM_LIT:2> * pi / <NUM_LIT:7> ) - <NUM_LIT:7> ) / ( <NUM_LIT:9> * cos ( pi / <NUM_LIT:7> ) - <NUM_LIT:5> * cos ( <NUM_LIT:3> * pi / <NUM_LIT:7> ) ) <EOL> mp = minimal_polynomial ( ex , x ) <EOL> assert mp == x ** <NUM_LIT:3> + <NUM_LIT:2> * x ** <NUM_LIT:2> - x - <NUM_LIT:1> <EOL> assert minimal_polynomial ( - <NUM_LIT:1> / ( <NUM_LIT:2> * cos ( pi / <NUM_LIT:7> ) ) , x ) == x ** <NUM_LIT:3> + <NUM_LIT:2> * x ** <NUM_LIT:2> - x - <NUM_LIT:1> <EOL> assert minimal_polynomial ( sin ( <NUM_LIT:2> * pi / <NUM_LIT:15> ) , x ) == <NUM_LIT> * x ** <NUM_LIT:8> - <NUM_LIT> * x ** <NUM_LIT:6> + <NUM_LIT> * x ** <NUM_LIT:4> - <NUM_LIT:32> * x ** <NUM_LIT:2> + <NUM_LIT:1> <EOL> assert minimal_polynomial ( sin ( <NUM_LIT:5> * pi / <NUM_LIT> ) , x ) == <NUM_LIT:8> * x ** <NUM_LIT:3> - <NUM_LIT:4> * x ** <NUM_LIT:2> - <NUM_LIT:4> * x + <NUM_LIT:1> <EOL> assert minimal_polynomial ( cos ( pi / <NUM_LIT:15> ) , x ) == <NUM_LIT:16> * x ** <NUM_LIT:4> + <NUM_LIT:8> * x ** <NUM_LIT:3> - <NUM_LIT:16> * x ** <NUM_LIT:2> - <NUM_LIT:8> * x + <NUM_LIT:1> <EOL> ex = rootof ( x ** <NUM_LIT:3> + x * <NUM_LIT:4> + <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> mp = minimal_polynomial ( ex , x ) <EOL> assert mp == x ** <NUM_LIT:3> + <NUM_LIT:4> * x + <NUM_LIT:1> <EOL> mp = minimal_polynomial ( ex + <NUM_LIT:1> , x ) <EOL> assert mp == x ** <NUM_LIT:3> - <NUM_LIT:3> * x ** <NUM_LIT:2> + <NUM_LIT:7> * x - <NUM_LIT:4> <EOL> assert minimal_polynomial ( exp ( I * pi / <NUM_LIT:3> ) , x ) == x ** <NUM_LIT:2> - x + <NUM_LIT:1> <EOL> assert minimal_polynomial ( exp ( I * pi / <NUM_LIT:4> ) , x ) == x ** <NUM_LIT:4> + <NUM_LIT:1> <EOL> assert minimal_polynomial ( exp ( I * pi / <NUM_LIT:6> ) , x ) == x ** <NUM_LIT:4> - x ** <NUM_LIT:2> + <NUM_LIT:1> <EOL> assert minimal_polynomial ( exp ( I * pi / <NUM_LIT:9> ) , x ) == x ** <NUM_LIT:6> - x ** <NUM_LIT:3> + <NUM_LIT:1> <EOL> assert minimal_polynomial ( exp ( I * pi / <NUM_LIT:10> ) , x ) == x ** <NUM_LIT:8> - x ** <NUM_LIT:6> + x ** <NUM_LIT:4> - x ** <NUM_LIT:2> + <NUM_LIT:1> <EOL> assert minimal_polynomial ( sin ( pi / <NUM_LIT:9> ) , x ) == <NUM_LIT:64> * x ** <NUM_LIT:6> - <NUM_LIT> * x ** <NUM_LIT:4> + <NUM_LIT> * x ** <NUM_LIT:2> - <NUM_LIT:3> <EOL> assert minimal_polynomial ( sin ( pi / <NUM_LIT:11> ) , x ) == <NUM_LIT> * x ** <NUM_LIT:10> - <NUM_LIT> * x ** <NUM_LIT:8> + <NUM_LIT> * x ** <NUM_LIT:6> - <NUM_LIT> * x ** <NUM_LIT:4> + <NUM_LIT> * x ** <NUM_LIT:2> - <NUM_LIT:11> <EOL> ex = <NUM_LIT:2> ** Rational ( <NUM_LIT:1> , <NUM_LIT:3> ) * exp ( Rational ( <NUM_LIT:2> , <NUM_LIT:3> ) * I * pi ) <EOL> assert minimal_polynomial ( ex , x ) == x ** <NUM_LIT:3> - <NUM_LIT:2> <EOL> raises ( NotAlgebraic , lambda : minimal_polynomial ( cos ( pi * sqrt ( <NUM_LIT:2> ) ) , x ) ) <EOL> raises ( NotAlgebraic , lambda : minimal_polynomial ( sin ( pi * sqrt ( <NUM_LIT:2> ) ) , x ) ) <EOL> raises ( NotAlgebraic , lambda : minimal_polynomial ( exp ( I * pi * sqrt ( <NUM_LIT:2> ) ) , x ) ) <EOL> ex = <NUM_LIT:1> / ( - <NUM_LIT> - <NUM_LIT> * sqrt ( <NUM_LIT:5> ) + ( <NUM_LIT:12> * sqrt ( <NUM_LIT:10> ) * sqrt ( sqrt ( <NUM_LIT:5> ) + <NUM_LIT:5> ) + <EOL> <NUM_LIT> * sqrt ( <NUM_LIT:10> ) * sqrt ( - sqrt ( <NUM_LIT:5> ) + <NUM_LIT:5> ) ) ** <NUM_LIT:2> ) + <NUM_LIT:1> <EOL> raises ( ZeroDivisionError , lambda : minimal_polynomial ( ex , x ) ) <EOL> ex = sqrt ( <NUM_LIT:1> + <NUM_LIT:2> ** Rational ( <NUM_LIT:1> , <NUM_LIT:3> ) ) + sqrt ( <NUM_LIT:1> + <NUM_LIT:2> ** Rational ( <NUM_LIT:1> , <NUM_LIT:4> ) ) + sqrt ( <NUM_LIT:2> ) <EOL> mp = minimal_polynomial ( ex , x ) <EOL> assert degree ( mp ) == <NUM_LIT> and mp . subs ( { x : <NUM_LIT:0> } ) == - <NUM_LIT> <EOL> def test_minpoly_issue_7113 ( ) : <EOL> from sympy . simplify . simplify import nsimplify <EOL> r = nsimplify ( pi , tolerance = <NUM_LIT> ) <EOL> mp = minimal_polynomial ( r , x ) <EOL> assert mp == <NUM_LIT> * x ** <NUM_LIT> - <NUM_LIT> <EOL> def test_minpoly_issue_7574 ( ) : <EOL> ex = - ( - <NUM_LIT:1> ) ** Rational ( <NUM_LIT:1> , <NUM_LIT:3> ) + ( - <NUM_LIT:1> ) ** Rational ( <NUM_LIT:2> , <NUM_LIT:3> ) <EOL> assert minimal_polynomial ( ex , x ) == x + <NUM_LIT:1> <EOL> def test_primitive_element ( ) : <EOL> assert primitive_element ( [ sqrt ( <NUM_LIT:2> ) ] , x ) == ( x ** <NUM_LIT:2> - <NUM_LIT:2> , [ <NUM_LIT:1> ] ) <EOL> assert primitive_element ( <EOL> [ sqrt ( <NUM_LIT:2> ) , sqrt ( <NUM_LIT:3> ) ] , x ) == ( x ** <NUM_LIT:4> - <NUM_LIT:10> * x ** <NUM_LIT:2> + <NUM_LIT:1> , [ <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> assert primitive_element ( [ sqrt ( <NUM_LIT:2> ) ] , x , polys = True ) == ( Poly ( x ** <NUM_LIT:2> - <NUM_LIT:2> ) , [ <NUM_LIT:1> ] ) <EOL> assert primitive_element ( [ sqrt ( <EOL> <NUM_LIT:2> ) , sqrt ( <NUM_LIT:3> ) ] , x , polys = True ) == ( Poly ( x ** <NUM_LIT:4> - <NUM_LIT:10> * x ** <NUM_LIT:2> + <NUM_LIT:1> ) , [ <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> assert primitive_element ( <EOL> [ sqrt ( <NUM_LIT:2> ) ] , x , ex = True ) == ( x ** <NUM_LIT:2> - <NUM_LIT:2> , [ <NUM_LIT:1> ] , [ [ <NUM_LIT:1> , <NUM_LIT:0> ] ] ) <EOL> assert primitive_element ( [ sqrt ( <NUM_LIT:2> ) , sqrt ( <NUM_LIT:3> ) ] , x , ex = True ) == ( x ** <NUM_LIT:4> - <NUM_LIT:10> * x ** <NUM_LIT:2> + <NUM_LIT:1> , [ <NUM_LIT:1> , <NUM_LIT:1> ] , [ [ Q ( <NUM_LIT:1> , <NUM_LIT:2> ) , <NUM_LIT:0> , - Q ( <NUM_LIT:9> , <NUM_LIT:2> ) , <NUM_LIT:0> ] , [ - <EOL> Q ( <NUM_LIT:1> , <NUM_LIT:2> ) , <NUM_LIT:0> , Q ( <NUM_LIT:11> , <NUM_LIT:2> ) , <NUM_LIT:0> ] ] ) <EOL> assert primitive_element ( <EOL> [ sqrt ( <NUM_LIT:2> ) ] , x , ex = True , polys = True ) == ( Poly ( x ** <NUM_LIT:2> - <NUM_LIT:2> ) , [ <NUM_LIT:1> ] , [ [ <NUM_LIT:1> , <NUM_LIT:0> ] ] ) <EOL> assert primitive_element ( [ sqrt ( <NUM_LIT:2> ) , sqrt ( <NUM_LIT:3> ) ] , x , ex = True , polys = True ) == ( Poly ( x ** <NUM_LIT:4> - <NUM_LIT:10> * x ** <NUM_LIT:2> + <NUM_LIT:1> ) , [ <NUM_LIT:1> , <NUM_LIT:1> ] , [ [ Q ( <NUM_LIT:1> , <NUM_LIT:2> ) , <NUM_LIT:0> , - Q ( <NUM_LIT:9> , <NUM_LIT:2> ) , <EOL> <NUM_LIT:0> ] , [ - Q ( <NUM_LIT:1> , <NUM_LIT:2> ) , <NUM_LIT:0> , Q ( <NUM_LIT:11> , <NUM_LIT:2> ) , <NUM_LIT:0> ] ] ) <EOL> assert primitive_element ( [ sqrt ( <NUM_LIT:2> ) ] , polys = True ) == ( Poly ( x ** <NUM_LIT:2> - <NUM_LIT:2> ) , [ <NUM_LIT:1> ] ) <EOL> raises ( ValueError , lambda : primitive_element ( [ ] , x , ex = False ) ) <EOL> raises ( ValueError , lambda : primitive_element ( [ ] , x , ex = True ) ) <EOL> def test_field_isomorphism_pslq ( ) : <EOL> a = AlgebraicNumber ( I ) <EOL> b = AlgebraicNumber ( I * sqrt ( <NUM_LIT:3> ) ) <EOL> raises ( NotImplementedError , lambda : field_isomorphism_pslq ( a , b ) ) <EOL> a = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) ) <EOL> b = AlgebraicNumber ( sqrt ( <NUM_LIT:3> ) ) <EOL> c = AlgebraicNumber ( sqrt ( <NUM_LIT:7> ) ) <EOL> d = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) + sqrt ( <NUM_LIT:3> ) ) <EOL> e = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) + sqrt ( <NUM_LIT:3> ) + sqrt ( <NUM_LIT:7> ) ) <EOL> assert field_isomorphism_pslq ( a , a ) == [ <NUM_LIT:1> , <NUM_LIT:0> ] <EOL> assert field_isomorphism_pslq ( a , b ) is None <EOL> assert field_isomorphism_pslq ( a , c ) is None <EOL> assert field_isomorphism_pslq ( a , d ) == [ Q ( <NUM_LIT:1> , <NUM_LIT:2> ) , <NUM_LIT:0> , - Q ( <NUM_LIT:9> , <NUM_LIT:2> ) , <NUM_LIT:0> ] <EOL> assert field_isomorphism_pslq ( <EOL> a , e ) == [ Q ( <NUM_LIT:1> , <NUM_LIT> ) , <NUM_LIT:0> , - Q ( <NUM_LIT:1> , <NUM_LIT:2> ) , <NUM_LIT:0> , Q ( <NUM_LIT> , <NUM_LIT:20> ) , <NUM_LIT:0> ] <EOL> assert field_isomorphism_pslq ( b , a ) is None <EOL> assert field_isomorphism_pslq ( b , b ) == [ <NUM_LIT:1> , <NUM_LIT:0> ] <EOL> assert field_isomorphism_pslq ( b , c ) is None <EOL> assert field_isomorphism_pslq ( b , d ) == [ - Q ( <NUM_LIT:1> , <NUM_LIT:2> ) , <NUM_LIT:0> , Q ( <NUM_LIT:11> , <NUM_LIT:2> ) , <NUM_LIT:0> ] <EOL> assert field_isomorphism_pslq ( b , e ) == [ - Q ( <EOL> <NUM_LIT:3> , <NUM_LIT> ) , <NUM_LIT:0> , Q ( <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT:0> , - Q ( <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT:0> , Q ( <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT:0> ] <EOL> assert field_isomorphism_pslq ( c , a ) is None <EOL> assert field_isomorphism_pslq ( c , b ) is None <EOL> assert field_isomorphism_pslq ( c , c ) == [ <NUM_LIT:1> , <NUM_LIT:0> ] <EOL> assert field_isomorphism_pslq ( c , d ) is None <EOL> assert field_isomorphism_pslq ( c , e ) == [ Q ( <EOL> <NUM_LIT:3> , <NUM_LIT> ) , <NUM_LIT:0> , - Q ( <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT:0> , Q ( <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT:0> , - Q ( <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT:0> ] <EOL> assert field_isomorphism_pslq ( d , a ) is None <EOL> assert field_isomorphism_pslq ( d , b ) is None <EOL> assert field_isomorphism_pslq ( d , c ) is None <EOL> assert field_isomorphism_pslq ( d , d ) == [ <NUM_LIT:1> , <NUM_LIT:0> ] <EOL> assert field_isomorphism_pslq ( d , e ) == [ - Q ( <EOL> <NUM_LIT:3> , <NUM_LIT> ) , <NUM_LIT:0> , Q ( <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT:0> , - Q ( <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT:0> , Q ( <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT:0> ] <EOL> assert field_isomorphism_pslq ( e , a ) is None <EOL> assert field_isomorphism_pslq ( e , b ) is None <EOL> assert field_isomorphism_pslq ( e , c ) is None <EOL> assert field_isomorphism_pslq ( e , d ) is None <EOL> assert field_isomorphism_pslq ( e , e ) == [ <NUM_LIT:1> , <NUM_LIT:0> ] <EOL> f = AlgebraicNumber ( <NUM_LIT:3> * sqrt ( <NUM_LIT:2> ) + <NUM_LIT:8> * sqrt ( <NUM_LIT:7> ) - <NUM_LIT:5> ) <EOL> assert field_isomorphism_pslq ( <EOL> f , e ) == [ Q ( <NUM_LIT:3> , <NUM_LIT> ) , <NUM_LIT:0> , - Q ( <NUM_LIT> , <NUM_LIT> ) , <NUM_LIT:0> , Q ( <NUM_LIT> , <NUM_LIT:20> ) , <NUM_LIT:0> , - Q ( <NUM_LIT> , <NUM_LIT:20> ) , - <NUM_LIT:5> ] <EOL> def test_field_isomorphism ( ) : <EOL> assert field_isomorphism ( <NUM_LIT:3> , sqrt ( <NUM_LIT:2> ) ) == [ <NUM_LIT:3> ] <EOL> assert field_isomorphism ( I * sqrt ( <NUM_LIT:3> ) , I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:2> ) == [ <NUM_LIT:2> , <NUM_LIT:0> ] <EOL> assert field_isomorphism ( - I * sqrt ( <NUM_LIT:3> ) , I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:2> ) == [ - <NUM_LIT:2> , <NUM_LIT:0> ] <EOL> assert field_isomorphism ( I * sqrt ( <NUM_LIT:3> ) , - I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:2> ) == [ - <NUM_LIT:2> , <NUM_LIT:0> ] <EOL> assert field_isomorphism ( - I * sqrt ( <NUM_LIT:3> ) , - I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:2> ) == [ <NUM_LIT:2> , <NUM_LIT:0> ] <EOL> assert field_isomorphism ( <NUM_LIT:2> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:7> , <NUM_LIT:5> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:3> ) == [ S ( <NUM_LIT:6> ) / <NUM_LIT> , <NUM_LIT:0> ] <EOL> assert field_isomorphism ( - <NUM_LIT:2> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:7> , <NUM_LIT:5> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:3> ) == [ - S ( <NUM_LIT:6> ) / <NUM_LIT> , <NUM_LIT:0> ] <EOL> assert field_isomorphism ( <NUM_LIT:2> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:7> , - <NUM_LIT:5> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:3> ) == [ - S ( <NUM_LIT:6> ) / <NUM_LIT> , <NUM_LIT:0> ] <EOL> assert field_isomorphism ( - <NUM_LIT:2> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:7> , - <NUM_LIT:5> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:3> ) == [ S ( <NUM_LIT:6> ) / <NUM_LIT> , <NUM_LIT:0> ] <EOL> assert field_isomorphism ( <EOL> <NUM_LIT:2> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:7> + <NUM_LIT> , <NUM_LIT:5> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:3> ) == [ S ( <NUM_LIT:6> ) / <NUM_LIT> , <NUM_LIT> ] <EOL> assert field_isomorphism ( <EOL> - <NUM_LIT:2> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:7> + <NUM_LIT> , <NUM_LIT:5> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:3> ) == [ - S ( <NUM_LIT:6> ) / <NUM_LIT> , <NUM_LIT> ] <EOL> assert field_isomorphism ( <EOL> <NUM_LIT:2> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:7> + <NUM_LIT> , - <NUM_LIT:5> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:3> ) == [ - S ( <NUM_LIT:6> ) / <NUM_LIT> , <NUM_LIT> ] <EOL> assert field_isomorphism ( <EOL> - <NUM_LIT:2> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:7> + <NUM_LIT> , - <NUM_LIT:5> * I * sqrt ( <NUM_LIT:3> ) / <NUM_LIT:3> ) == [ S ( <NUM_LIT:6> ) / <NUM_LIT> , <NUM_LIT> ] <EOL> p = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) + sqrt ( <NUM_LIT:3> ) ) <EOL> q = AlgebraicNumber ( - sqrt ( <NUM_LIT:2> ) + sqrt ( <NUM_LIT:3> ) ) <EOL> r = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) - sqrt ( <NUM_LIT:3> ) ) <EOL> s = AlgebraicNumber ( - sqrt ( <NUM_LIT:2> ) - sqrt ( <NUM_LIT:3> ) ) <EOL> pos_coeffs = [ S ( <NUM_LIT:1> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) , - S ( <NUM_LIT:9> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) ] <EOL> neg_coeffs = [ - S ( <NUM_LIT:1> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) , S ( <NUM_LIT:9> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) ] <EOL> a = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) ) <EOL> assert is_isomorphism_possible ( a , p ) is True <EOL> assert is_isomorphism_possible ( a , q ) is True <EOL> assert is_isomorphism_possible ( a , r ) is True <EOL> assert is_isomorphism_possible ( a , s ) is True <EOL> assert field_isomorphism ( a , p , fast = True ) == pos_coeffs <EOL> assert field_isomorphism ( a , q , fast = True ) == neg_coeffs <EOL> assert field_isomorphism ( a , r , fast = True ) == pos_coeffs <EOL> assert field_isomorphism ( a , s , fast = True ) == neg_coeffs <EOL> assert field_isomorphism ( a , p , fast = False ) == pos_coeffs <EOL> assert field_isomorphism ( a , q , fast = False ) == neg_coeffs <EOL> assert field_isomorphism ( a , r , fast = False ) == pos_coeffs <EOL> assert field_isomorphism ( a , s , fast = False ) == neg_coeffs <EOL> a = AlgebraicNumber ( - sqrt ( <NUM_LIT:2> ) ) <EOL> assert is_isomorphism_possible ( a , p ) is True <EOL> assert is_isomorphism_possible ( a , q ) is True <EOL> assert is_isomorphism_possible ( a , r ) is True <EOL> assert is_isomorphism_possible ( a , s ) is True <EOL> assert field_isomorphism ( a , p , fast = True ) == neg_coeffs <EOL> assert field_isomorphism ( a , q , fast = True ) == pos_coeffs <EOL> assert field_isomorphism ( a , r , fast = True ) == neg_coeffs <EOL> assert field_isomorphism ( a , s , fast = True ) == pos_coeffs <EOL> assert field_isomorphism ( a , p , fast = False ) == neg_coeffs <EOL> assert field_isomorphism ( a , q , fast = False ) == pos_coeffs <EOL> assert field_isomorphism ( a , r , fast = False ) == neg_coeffs <EOL> assert field_isomorphism ( a , s , fast = False ) == pos_coeffs <EOL> pos_coeffs = [ S ( <NUM_LIT:1> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) , - S ( <NUM_LIT:11> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) ] <EOL> neg_coeffs = [ - S ( <NUM_LIT:1> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) , S ( <NUM_LIT:11> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) ] <EOL> a = AlgebraicNumber ( sqrt ( <NUM_LIT:3> ) ) <EOL> assert is_isomorphism_possible ( a , p ) is True <EOL> assert is_isomorphism_possible ( a , q ) is True <EOL> assert is_isomorphism_possible ( a , r ) is True <EOL> assert is_isomorphism_possible ( a , s ) is True <EOL> assert field_isomorphism ( a , p , fast = True ) == neg_coeffs <EOL> assert field_isomorphism ( a , q , fast = True ) == neg_coeffs <EOL> assert field_isomorphism ( a , r , fast = True ) == pos_coeffs <EOL> assert field_isomorphism ( a , s , fast = True ) == pos_coeffs <EOL> assert field_isomorphism ( a , p , fast = False ) == neg_coeffs <EOL> assert field_isomorphism ( a , q , fast = False ) == neg_coeffs <EOL> assert field_isomorphism ( a , r , fast = False ) == pos_coeffs <EOL> assert field_isomorphism ( a , s , fast = False ) == pos_coeffs <EOL> a = AlgebraicNumber ( - sqrt ( <NUM_LIT:3> ) ) <EOL> assert is_isomorphism_possible ( a , p ) is True <EOL> assert is_isomorphism_possible ( a , q ) is True <EOL> assert is_isomorphism_possible ( a , r ) is True <EOL> assert is_isomorphism_possible ( a , s ) is True <EOL> assert field_isomorphism ( a , p , fast = True ) == pos_coeffs <EOL> assert field_isomorphism ( a , q , fast = True ) == pos_coeffs <EOL> assert field_isomorphism ( a , r , fast = True ) == neg_coeffs <EOL> assert field_isomorphism ( a , s , fast = True ) == neg_coeffs <EOL> assert field_isomorphism ( a , p , fast = False ) == pos_coeffs <EOL> assert field_isomorphism ( a , q , fast = False ) == pos_coeffs <EOL> assert field_isomorphism ( a , r , fast = False ) == neg_coeffs <EOL> assert field_isomorphism ( a , s , fast = False ) == neg_coeffs <EOL> pos_coeffs = [ S ( <NUM_LIT:3> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) , - S ( <NUM_LIT> ) / <NUM_LIT:2> , - S ( <NUM_LIT:8> ) ] <EOL> neg_coeffs = [ - S ( <NUM_LIT:3> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) , S ( <NUM_LIT> ) / <NUM_LIT:2> , - S ( <NUM_LIT:8> ) ] <EOL> a = AlgebraicNumber ( <NUM_LIT:3> * sqrt ( <NUM_LIT:3> ) - <NUM_LIT:8> ) <EOL> assert is_isomorphism_possible ( a , p ) is True <EOL> assert is_isomorphism_possible ( a , q ) is True <EOL> assert is_isomorphism_possible ( a , r ) is True <EOL> assert is_isomorphism_possible ( a , s ) is True <EOL> assert field_isomorphism ( a , p , fast = True ) == neg_coeffs <EOL> assert field_isomorphism ( a , q , fast = True ) == neg_coeffs <EOL> assert field_isomorphism ( a , r , fast = True ) == pos_coeffs <EOL> assert field_isomorphism ( a , s , fast = True ) == pos_coeffs <EOL> assert field_isomorphism ( a , p , fast = False ) == neg_coeffs <EOL> assert field_isomorphism ( a , q , fast = False ) == neg_coeffs <EOL> assert field_isomorphism ( a , r , fast = False ) == pos_coeffs <EOL> assert field_isomorphism ( a , s , fast = False ) == pos_coeffs <EOL> a = AlgebraicNumber ( <NUM_LIT:3> * sqrt ( <NUM_LIT:2> ) + <NUM_LIT:2> * sqrt ( <NUM_LIT:3> ) + <NUM_LIT:1> ) <EOL> pos_1_coeffs = [ S ( <NUM_LIT:1> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) , - S ( <NUM_LIT:5> ) / <NUM_LIT:2> , S ( <NUM_LIT:1> ) ] <EOL> neg_5_coeffs = [ - S ( <NUM_LIT:5> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) , S ( <NUM_LIT> ) / <NUM_LIT:2> , S ( <NUM_LIT:1> ) ] <EOL> pos_5_coeffs = [ S ( <NUM_LIT:5> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) , - S ( <NUM_LIT> ) / <NUM_LIT:2> , S ( <NUM_LIT:1> ) ] <EOL> neg_1_coeffs = [ - S ( <NUM_LIT:1> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) , S ( <NUM_LIT:5> ) / <NUM_LIT:2> , S ( <NUM_LIT:1> ) ] <EOL> assert is_isomorphism_possible ( a , p ) is True <EOL> assert is_isomorphism_possible ( a , q ) is True <EOL> assert is_isomorphism_possible ( a , r ) is True <EOL> assert is_isomorphism_possible ( a , s ) is True <EOL> assert field_isomorphism ( a , p , fast = True ) == pos_1_coeffs <EOL> assert field_isomorphism ( a , q , fast = True ) == neg_5_coeffs <EOL> assert field_isomorphism ( a , r , fast = True ) == pos_5_coeffs <EOL> assert field_isomorphism ( a , s , fast = True ) == neg_1_coeffs <EOL> assert field_isomorphism ( a , p , fast = False ) == pos_1_coeffs <EOL> assert field_isomorphism ( a , q , fast = False ) == neg_5_coeffs <EOL> assert field_isomorphism ( a , r , fast = False ) == pos_5_coeffs <EOL> assert field_isomorphism ( a , s , fast = False ) == neg_1_coeffs <EOL> a = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) ) <EOL> b = AlgebraicNumber ( sqrt ( <NUM_LIT:3> ) ) <EOL> c = AlgebraicNumber ( sqrt ( <NUM_LIT:7> ) ) <EOL> assert is_isomorphism_possible ( a , b ) is True <EOL> assert is_isomorphism_possible ( b , a ) is True <EOL> assert is_isomorphism_possible ( c , p ) is False <EOL> assert field_isomorphism ( sqrt ( <NUM_LIT:2> ) , sqrt ( <NUM_LIT:3> ) , fast = True ) is None <EOL> assert field_isomorphism ( sqrt ( <NUM_LIT:3> ) , sqrt ( <NUM_LIT:2> ) , fast = True ) is None <EOL> assert field_isomorphism ( sqrt ( <NUM_LIT:2> ) , sqrt ( <NUM_LIT:3> ) , fast = False ) is None <EOL> assert field_isomorphism ( sqrt ( <NUM_LIT:3> ) , sqrt ( <NUM_LIT:2> ) , fast = False ) is None <EOL> def test_to_number_field ( ) : <EOL> assert to_number_field ( sqrt ( <NUM_LIT:2> ) ) == AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) ) <EOL> assert to_number_field ( <EOL> [ sqrt ( <NUM_LIT:2> ) , sqrt ( <NUM_LIT:3> ) ] ) == AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) + sqrt ( <NUM_LIT:3> ) ) <EOL> a = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) + sqrt ( <NUM_LIT:3> ) , [ S ( <NUM_LIT:1> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) , - S ( <NUM_LIT:9> ) / <NUM_LIT:2> , S ( <NUM_LIT:0> ) ] ) <EOL> assert to_number_field ( sqrt ( <NUM_LIT:2> ) , sqrt ( <NUM_LIT:2> ) + sqrt ( <NUM_LIT:3> ) ) == a <EOL> assert to_number_field ( sqrt ( <NUM_LIT:2> ) , AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) + sqrt ( <NUM_LIT:3> ) ) ) == a <EOL> raises ( IsomorphismFailed , lambda : to_number_field ( sqrt ( <NUM_LIT:2> ) , sqrt ( <NUM_LIT:3> ) ) ) <EOL> def test_AlgebraicNumber ( ) : <EOL> minpoly , root = x ** <NUM_LIT:2> - <NUM_LIT:2> , sqrt ( <NUM_LIT:2> ) <EOL> a = AlgebraicNumber ( root , gen = x ) <EOL> assert a . rep == DMP ( [ QQ ( <NUM_LIT:1> ) , QQ ( <NUM_LIT:0> ) ] , QQ ) <EOL> assert a . root == root <EOL> assert a . alias is None <EOL> assert a . minpoly == minpoly <EOL> assert a . is_number <EOL> assert a . is_aliased is False <EOL> assert a . coeffs ( ) == [ S ( <NUM_LIT:1> ) , S ( <NUM_LIT:0> ) ] <EOL> assert a . native_coeffs ( ) == [ QQ ( <NUM_LIT:1> ) , QQ ( <NUM_LIT:0> ) ] <EOL> a = AlgebraicNumber ( root , gen = x , alias = '<STR_LIT:y>' ) <EOL> assert a . rep == DMP ( [ QQ ( <NUM_LIT:1> ) , QQ ( <NUM_LIT:0> ) ] , QQ ) <EOL> assert a . root == root <EOL> assert a . alias == Symbol ( '<STR_LIT:y>' ) <EOL> assert a . minpoly == minpoly <EOL> assert a . is_number <EOL> assert a . is_aliased is True <EOL> a = AlgebraicNumber ( root , gen = x , alias = Symbol ( '<STR_LIT:y>' ) ) <EOL> assert a . rep == DMP ( [ QQ ( <NUM_LIT:1> ) , QQ ( <NUM_LIT:0> ) ] , QQ ) <EOL> assert a . root == root <EOL> assert a . alias == Symbol ( '<STR_LIT:y>' ) <EOL> assert a . minpoly == minpoly <EOL> assert a . is_number <EOL> assert a . is_aliased is True <EOL> assert AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , [ ] ) . rep == DMP ( [ ] , QQ ) <EOL> assert AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , ( ) ) . rep == DMP ( [ ] , QQ ) <EOL> assert AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , ( <NUM_LIT:0> , <NUM_LIT:0> ) ) . rep == DMP ( [ ] , QQ ) <EOL> assert AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , [ <NUM_LIT:8> ] ) . rep == DMP ( [ QQ ( <NUM_LIT:8> ) ] , QQ ) <EOL> assert AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , [ S ( <NUM_LIT:8> ) / <NUM_LIT:3> ] ) . rep == DMP ( [ QQ ( <NUM_LIT:8> , <NUM_LIT:3> ) ] , QQ ) <EOL> assert AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , [ <NUM_LIT:7> , <NUM_LIT:3> ] ) . rep == DMP ( [ QQ ( <NUM_LIT:7> ) , QQ ( <NUM_LIT:3> ) ] , QQ ) <EOL> assert AlgebraicNumber ( <EOL> sqrt ( <NUM_LIT:2> ) , [ S ( <NUM_LIT:7> ) / <NUM_LIT:9> , S ( <NUM_LIT:3> ) / <NUM_LIT:2> ] ) . rep == DMP ( [ QQ ( <NUM_LIT:7> , <NUM_LIT:9> ) , QQ ( <NUM_LIT:3> , <NUM_LIT:2> ) ] , QQ ) <EOL> assert AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) . rep == DMP ( [ QQ ( <NUM_LIT:2> ) , QQ ( <NUM_LIT:5> ) ] , QQ ) <EOL> a = AlgebraicNumber ( AlgebraicNumber ( root , gen = x ) , [ <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> assert a . rep == DMP ( [ QQ ( <NUM_LIT:1> ) , QQ ( <NUM_LIT:2> ) ] , QQ ) <EOL> assert a . root == root <EOL> assert a . alias is None <EOL> assert a . minpoly == minpoly <EOL> assert a . is_number <EOL> assert a . is_aliased is False <EOL> assert a . coeffs ( ) == [ S ( <NUM_LIT:1> ) , S ( <NUM_LIT:2> ) ] <EOL> assert a . native_coeffs ( ) == [ QQ ( <NUM_LIT:1> ) , QQ ( <NUM_LIT:2> ) ] <EOL> a = AlgebraicNumber ( ( minpoly , root ) , [ <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> assert a . rep == DMP ( [ QQ ( <NUM_LIT:1> ) , QQ ( <NUM_LIT:2> ) ] , QQ ) <EOL> assert a . root == root <EOL> assert a . alias is None <EOL> assert a . minpoly == minpoly <EOL> assert a . is_number <EOL> assert a . is_aliased is False <EOL> a = AlgebraicNumber ( ( Poly ( minpoly ) , root ) , [ <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> assert a . rep == DMP ( [ QQ ( <NUM_LIT:1> ) , QQ ( <NUM_LIT:2> ) ] , QQ ) <EOL> assert a . root == root <EOL> assert a . alias is None <EOL> assert a . minpoly == minpoly <EOL> assert a . is_number <EOL> assert a . is_aliased is False <EOL> assert AlgebraicNumber ( sqrt ( <NUM_LIT:3> ) ) . rep == DMP ( [ QQ ( <NUM_LIT:1> ) , QQ ( <NUM_LIT:0> ) ] , QQ ) <EOL> assert AlgebraicNumber ( - sqrt ( <NUM_LIT:3> ) ) . rep == DMP ( [ - QQ ( <NUM_LIT:1> ) , QQ ( <NUM_LIT:0> ) ] , QQ ) <EOL> a = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) ) <EOL> b = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) ) <EOL> assert a == b <EOL> c = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , gen = x ) <EOL> d = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , gen = x ) <EOL> assert a == b <EOL> assert a == c <EOL> a = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , [ <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> b = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , [ <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> assert a != b and a != sqrt ( <NUM_LIT:2> ) + <NUM_LIT:3> <EOL> assert ( a == x ) is False and ( a != x ) is True <EOL> a = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , [ <NUM_LIT:1> , <NUM_LIT:0> ] ) <EOL> b = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , [ <NUM_LIT:1> , <NUM_LIT:0> ] , alias = y ) <EOL> assert a . as_poly ( x ) == Poly ( x ) <EOL> assert b . as_poly ( ) == Poly ( y ) <EOL> assert a . as_expr ( ) == sqrt ( <NUM_LIT:2> ) <EOL> assert a . as_expr ( x ) == x <EOL> assert b . as_expr ( ) == sqrt ( <NUM_LIT:2> ) <EOL> assert b . as_expr ( x ) == x <EOL> a = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , [ <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> b = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , [ <NUM_LIT:2> , <NUM_LIT:3> ] , alias = y ) <EOL> p = a . as_poly ( ) <EOL> assert p == Poly ( <NUM_LIT:2> * p . gen + <NUM_LIT:3> ) <EOL> assert a . as_poly ( x ) == Poly ( <NUM_LIT:2> * x + <NUM_LIT:3> ) <EOL> assert b . as_poly ( ) == Poly ( <NUM_LIT:2> * y + <NUM_LIT:3> ) <EOL> assert a . as_expr ( ) == <NUM_LIT:2> * sqrt ( <NUM_LIT:2> ) + <NUM_LIT:3> <EOL> assert a . as_expr ( x ) == <NUM_LIT:2> * x + <NUM_LIT:3> <EOL> assert b . as_expr ( ) == <NUM_LIT:2> * sqrt ( <NUM_LIT:2> ) + <NUM_LIT:3> <EOL> assert b . as_expr ( x ) == <NUM_LIT:2> * x + <NUM_LIT:3> <EOL> a = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) ) <EOL> b = to_number_field ( sqrt ( <NUM_LIT:2> ) ) <EOL> assert a . args == b . args == ( sqrt ( <NUM_LIT:2> ) , Tuple ( <NUM_LIT:1> , <NUM_LIT:0> ) ) <EOL> b = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , alias = '<STR_LIT>' ) <EOL> assert b . args == ( sqrt ( <NUM_LIT:2> ) , Tuple ( <NUM_LIT:1> , <NUM_LIT:0> ) , Symbol ( '<STR_LIT>' ) ) <EOL> a = AlgebraicNumber ( sqrt ( <NUM_LIT:2> ) , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> assert a . args == ( sqrt ( <NUM_LIT:2> ) , Tuple ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> def test_to_algebraic_integer ( ) : <EOL> a = AlgebraicNumber ( sqrt ( <NUM_LIT:3> ) , gen = x ) . to_algebraic_integer ( ) <EOL> assert a . minpoly == x ** <NUM_LIT:2> - <NUM_LIT:3> <EOL> assert a . root == sqrt ( <NUM_LIT:3> ) <EOL> assert a . rep == DMP ( [ QQ ( <NUM_LIT:1> ) , QQ ( <NUM_LIT:0> ) ] , QQ ) <EOL> a = AlgebraicNumber ( <NUM_LIT:2> * sqrt ( <NUM_LIT:3> ) , gen = x ) . to_algebraic_integer ( ) <EOL> assert a . minpoly == x ** <NUM_LIT:2> - <NUM_LIT:12> <EOL> assert a . root == <NUM_LIT:2> * sqrt ( <NUM_LIT:3> ) <EOL> assert a . rep == DMP ( [ QQ ( <NUM_LIT:1> ) , QQ ( <NUM_LIT:0> ) ] , QQ ) <EOL> a = AlgebraicNumber ( sqrt ( <NUM_LIT:3> ) / <NUM_LIT:2> , gen = x ) . to_algebraic_integer ( ) <EOL> assert a . minpoly == x ** <NUM_LIT:2> - <NUM_LIT:12> <EOL> assert a . root == <NUM_LIT:2> * sqrt ( <NUM_LIT:3> ) <EOL> assert a . rep == DMP ( [ QQ ( <NUM_LIT:1> ) , QQ ( <NUM_LIT:0> ) ] , QQ ) <EOL> a = AlgebraicNumber ( sqrt ( <NUM_LIT:3> ) / <NUM_LIT:2> , [ S ( <NUM_LIT:7> ) / <NUM_LIT> , <NUM_LIT:3> ] , gen = x ) . to_algebraic_integer ( ) <EOL> assert a . minpoly == x ** <NUM_LIT:2> - <NUM_LIT:12> <EOL> assert a . root == <NUM_LIT:2> * sqrt ( <NUM_LIT:3> ) <EOL> assert a . rep == DMP ( [ QQ ( <NUM_LIT:7> , <NUM_LIT> ) , QQ ( <NUM_LIT:3> ) ] , QQ ) <EOL> def test_IntervalPrinter ( ) : <EOL> ip = IntervalPrinter ( ) <EOL> assert ip . doprint ( x ** Q ( <NUM_LIT:1> , <NUM_LIT:3> ) ) == "<STR_LIT>" <EOL> assert ip . doprint ( sqrt ( x ) ) == "<STR_LIT>" <EOL> def test_isolate ( ) : <EOL> assert isolate ( <NUM_LIT:1> ) == ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> assert isolate ( S ( <NUM_LIT:1> ) / <NUM_LIT:2> ) == ( S ( <NUM_LIT:1> ) / <NUM_LIT:2> , S ( <NUM_LIT:1> ) / <NUM_LIT:2> ) <EOL> assert isolate ( sqrt ( <NUM_LIT:2> ) ) == ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> assert isolate ( - sqrt ( <NUM_LIT:2> ) ) == ( - <NUM_LIT:2> , - <NUM_LIT:1> ) <EOL> assert isolate ( sqrt ( <NUM_LIT:2> ) , eps = S ( <NUM_LIT:1> ) / <NUM_LIT:100> ) == ( S ( <NUM_LIT> ) / <NUM_LIT> , S ( <NUM_LIT> ) / <NUM_LIT:12> ) <EOL> assert isolate ( - sqrt ( <NUM_LIT:2> ) , eps = S ( <NUM_LIT:1> ) / <NUM_LIT:100> ) == ( - S ( <NUM_LIT> ) / <NUM_LIT:12> , - S ( <NUM_LIT> ) / <NUM_LIT> ) <EOL> raises ( NotImplementedError , lambda : isolate ( I ) ) <EOL> def test_minpoly_fraction_field ( ) : <EOL> assert minimal_polynomial ( <NUM_LIT:1> / x , y ) == - x * y + <NUM_LIT:1> <EOL> assert minimal_polynomial ( <NUM_LIT:1> / ( x + <NUM_LIT:1> ) , y ) == ( x + <NUM_LIT:1> ) * y - <NUM_LIT:1> <EOL> assert minimal_polynomial ( sqrt ( x ) , y ) == y ** <NUM_LIT:2> - x <EOL> assert minimal_polynomial ( sqrt ( x + <NUM_LIT:1> ) , y ) == y ** <NUM_LIT:2> - x - <NUM_LIT:1> <EOL> assert minimal_polynomial ( sqrt ( x ) / x , y ) == x * y ** <NUM_LIT:2> - <NUM_LIT:1> <EOL> assert minimal_polynomial ( sqrt ( <NUM_LIT:2> ) * sqrt ( x ) , y ) == y ** <NUM_LIT:2> - <NUM_LIT:2> * x <EOL> assert minimal_polynomial ( sqrt ( <NUM_LIT:2> ) + sqrt ( x ) , y ) == y ** <NUM_LIT:4> + ( - <NUM_LIT:2> * x - <NUM_LIT:4> ) * y ** <NUM_LIT:2> + x ** <NUM_LIT:2> - <NUM_LIT:4> * x + <NUM_LIT:4> <EOL> assert minimal_polynomial ( x ** Rational ( <NUM_LIT:1> , <NUM_LIT:3> ) , y ) == y ** <NUM_LIT:3> - x <EOL> assert minimal_polynomial ( x ** Rational ( <NUM_LIT:1> , <NUM_LIT:3> ) + sqrt ( x ) , y ) == y ** <NUM_LIT:6> - <NUM_LIT:3> * x * y ** <NUM_LIT:4> - <NUM_LIT:2> * x * y ** <NUM_LIT:3> + <NUM_LIT:3> * x ** <NUM_LIT:2> * y ** <NUM_LIT:2> - <NUM_LIT:6> * x ** <NUM_LIT:2> * y - x ** <NUM_LIT:3> + x ** <NUM_LIT:2> <EOL> assert minimal_polynomial ( sqrt ( x ) / z , y ) == z ** <NUM_LIT:2> * y ** <NUM_LIT:2> - x <EOL> assert minimal_polynomial ( sqrt ( x ) / ( z + <NUM_LIT:1> ) , y ) == ( z ** <NUM_LIT:2> + <NUM_LIT:2> * z + <NUM_LIT:1> ) * y ** <NUM_LIT:2> - x <EOL> assert minimal_polynomial ( <NUM_LIT:1> / x , y , polys = True ) == Poly ( - x * y + <NUM_LIT:1> , y ) <EOL> assert minimal_polynomial ( <NUM_LIT:1> / ( x + <NUM_LIT:1> ) , y , polys = True ) == Poly ( ( x + <NUM_LIT:1> ) * y - <NUM_LIT:1> , y ) <EOL> assert minimal_polynomial ( sqrt ( x ) , y , polys = True ) == Poly ( y ** <NUM_LIT:2> - x , y ) <EOL> assert minimal_polynomial ( sqrt ( x ) / z , y , polys = True ) == Poly ( z ** <NUM_LIT:2> * y ** <NUM_LIT:2> - x , y ) <EOL> a = sqrt ( x ) / sqrt ( <NUM_LIT:1> + x ** ( - <NUM_LIT:3> ) ) - sqrt ( x ** <NUM_LIT:3> + <NUM_LIT:1> ) / x + <NUM_LIT:1> / ( x ** ( S ( <NUM_LIT:5> ) / <NUM_LIT:2> ) * ( <NUM_LIT:1> + x ** ( - <NUM_LIT:3> ) ) ** ( S ( <NUM_LIT:3> ) / <NUM_LIT:2> ) ) + <NUM_LIT:1> / ( x ** ( S ( <NUM_LIT:11> ) / <NUM_LIT:2> ) * ( <NUM_LIT:1> + x ** ( - <NUM_LIT:3> ) ) ** ( S ( <NUM_LIT:3> ) / <NUM_LIT:2> ) ) <EOL> assert minimal_polynomial ( a , y ) == y <EOL> raises ( NotAlgebraic , lambda : minimal_polynomial ( exp ( x ) , y ) ) <EOL> raises ( GeneratorsError , lambda : minimal_polynomial ( sqrt ( x ) , x ) ) <EOL> raises ( GeneratorsError , lambda : minimal_polynomial ( sqrt ( x ) - y , x ) ) <EOL> raises ( NotImplementedError , lambda : minimal_polynomial ( sqrt ( x ) , y , compose = False ) ) <EOL> @ slow <EOL> def test_minpoly_fraction_field_slow ( ) : <EOL> assert minimal_polynomial ( minimal_polynomial ( sqrt ( x ** Rational ( <NUM_LIT:1> , <NUM_LIT:5> ) - <NUM_LIT:1> ) , <EOL> y ) . subs ( y , sqrt ( x ** Rational ( <NUM_LIT:1> , <NUM_LIT:5> ) - <NUM_LIT:1> ) ) , z ) == z <EOL> def test_minpoly_domain ( ) : <EOL> assert minimal_polynomial ( sqrt ( <NUM_LIT:2> ) , x , domain = QQ . algebraic_field ( sqrt ( <NUM_LIT:2> ) ) ) == x - sqrt ( <NUM_LIT:2> ) <EOL> assert minimal_polynomial ( sqrt ( <NUM_LIT:8> ) , x , domain = QQ . algebraic_field ( sqrt ( <NUM_LIT:2> ) ) ) == x - <NUM_LIT:2> * sqrt ( <NUM_LIT:2> ) <EOL> assert minimal_polynomial ( sqrt ( Rational ( <NUM_LIT:3> , <NUM_LIT:2> ) ) , x , <EOL> domain = QQ . algebraic_field ( sqrt ( <NUM_LIT:2> ) ) ) == <NUM_LIT:2> * x ** <NUM_LIT:2> - <NUM_LIT:3> <EOL> raises ( NotAlgebraic , lambda : minimal_polynomial ( y , x , domain = QQ ) ) </s>
