@@ -2834,6 +2834,36 @@ def setbad(obj, i, val):
28342834 if type (p ) == flint .fq_default_poly :
28352835 assert raises (lambda : p .integral (), NotImplementedError )
28362836
2837+ # resultant checks.
2838+
2839+ if is_field and characteristic == 0 :
2840+ # Check that the resultant of two cyclotomic polynomials is right.
2841+ # See Dresden's 2012 "Resultants of Cyclotomic Polynomials"
2842+ for m in range (1 , 50 ):
2843+ for n in range (m + 1 , 50 ):
2844+ a = flint .fmpz_poly .cyclotomic (m )
2845+ b = flint .fmpz_poly .cyclotomic (n )
2846+ q , r = divmod (flint .fmpz (n ), flint .fmpz (m ))
2847+ fs = q .factor ()
2848+ if r != 0 or len (fs ) > 1 :
2849+ assert a .resultant (b ) == 1
2850+ else :
2851+ prime = fs [0 ][0 ]
2852+ tot = flint .fmpz (m ).euler_phi ()
2853+ assert a .resultant (b ) == prime ** tot
2854+
2855+ x = P ([0 , 1 ])
2856+ # Flint does not implement resultants over GF(q) for nonprime q, so we
2857+ # there's nothing for us to check.
2858+ if composite_characteristic or type (x ) == flint .fq_default_poly :
2859+ pass
2860+ else :
2861+ assert x .resultant (x ) == 0
2862+ assert x .resultant (x ** 2 + x - x ) == 0
2863+
2864+ for k in range (- 10 , 10 ):
2865+ assert x .resultant (x + S (k )) == S (k )
2866+ assert x .resultant (x ** 10 - x ** 5 + 1 ) == S (1 )
28372867
28382868def _all_mpolys ():
28392869 return [
@@ -2869,7 +2899,6 @@ def _all_mpolys():
28692899 ),
28702900 ]
28712901
2872-
28732902def test_mpolys ():
28742903 for P , get_context , S , is_field , characteristic in _all_mpolys ():
28752904
0 commit comments