def test_get_dixon_matrix(): """Test Dixon's resultant for a numerical example.""" x, y = symbols('x, y') p = x + y q = x ** 2 + y ** 3 h = x ** 2 + y dixon = DixonResultant([p, q, h], [x, y]) polynomial = dixon.get_dixon_polynomial() assert dixon.get_dixon_matrix(polynomial).det() == 0
def test_get_KSY_Dixon_resultant_example_one(): """Tests the KSY Dixon resultant for example one""" x, y, z = symbols('x, y, z') p = x * y * z q = x**2 - z**2 h = x + y + z dixon = DixonResultant([p, q, h], [x, y]) dixon_poly = dixon.get_dixon_polynomial() dixon_matrix = dixon.get_dixon_matrix(dixon_poly) D = dixon.get_KSY_Dixon_resultant(dixon_matrix) assert D == -z**3
def test_get_dixon_matrix(): """Test Dixon's resultant for a numerical example.""" x, y = symbols('x, y') p = x + y q = x ** 2 + y ** 3 h = x ** 2 + y dixon = DixonResultant([p, q, h], [x, y]) polynomial = dixon.get_dixon_polynomial() assert dixon.get_dixon_matrix(polynomial).det() == 0
def test_get_dixon_matrix_example_two(): """Test Dixon's matrix for example from [Palancz08]_.""" x, y, z = symbols('x, y, z') f = x ** 2 + y ** 2 - 1 + z * 0 g = x ** 2 + z ** 2 - 1 + y * 0 h = y ** 2 + z ** 2 - 1 example_two = DixonResultant([f, g, h], [y, z]) poly = example_two.get_dixon_polynomial() matrix = example_two.get_dixon_matrix(poly) expr = 1 - 8 * x ** 2 + 24 * x ** 4 - 32 * x ** 6 + 16 * x ** 8 assert (matrix.det() - expr).expand() == 0
def test_get_KSY_Dixon_resultant_example_two(): """Tests the KSY Dixon resultant for example two""" x, y, A = symbols('x, y, A') p = x * y + x * A + x - A**2 - A + y**2 + y q = x**2 + x * A - x + x * y + y * A - y h = x**2 + x * y + 2 * x - x * A - y * A - 2 * A dixon = DixonResultant([p, q, h], [x, y]) dixon_poly = dixon.get_dixon_polynomial() dixon_matrix = dixon.get_dixon_matrix(dixon_poly) D = factor(dixon.get_KSY_Dixon_resultant(dixon_matrix)) assert D == -8 * A * (A - 1) * (A + 2) * (2 * A - 1)**2
def test_get_dixon_matrix_example_two(): """Test Dixon's matrix for example from [Palancz08]_.""" x, y, z = symbols('x, y, z') f = x ** 2 + y ** 2 - 1 + z * 0 g = x ** 2 + z ** 2 - 1 + y * 0 h = y ** 2 + z ** 2 - 1 example_two = DixonResultant([f, g, h], [y, z]) poly = example_two.get_dixon_polynomial() matrix = example_two.get_dixon_matrix(poly) expr = 1 - 8 * x ** 2 + 24 * x ** 4 - 32 * x ** 6 + 16 * x ** 8 assert (matrix.det() - expr).expand() == 0