def test_solve_biquadratic(): x0, y0, x1, y1, r = symbols('x0 y0 x1 y1 r') f_1 = (x - 1)**2 + (y - 1)**2 - r**2 f_2 = (x - 2)**2 + (y - 2)**2 - r**2 assert solve_poly_system([f_1, f_2], x, y) == \ [(S(3)/2 + (-1 + 2*r**2)**(S(1)/2)/2, S(3)/2 - (-1 + 2*r**2)**(S(1)/2)/2), (S(3)/2 - (-1 + 2*r**2)**(S(1)/2)/2, S(3)/2 + (-1 + 2*r**2)**(S(1)/2)/2)] f_1 = (x - 1)**2 + (y - 2)**2 - r**2 f_2 = (x - 1)**2 + (y - 1)**2 - r**2 assert solve_poly_system([f_1, f_2], x, y) == \ [(1 + (((2*r - 1)*(2*r + 1)))**(S(1)/2)/2, S(3)/2), (1 - (((2*r - 1)*(2*r + 1)))**(S(1)/2)/2, S(3)/2)] query = lambda expr: expr.is_Pow and expr.exp is S.Half f_1 = (x - 1)**2 + (y - 2)**2 - r**2 f_2 = (x - x1)**2 + (y - 1)**2 - r**2 result = solve_poly_system([f_1, f_2], x, y) assert len(result) == 2 and all(len(r) == 2 for r in result) assert all(r.count(query) == 1 for r in flatten(result)) f_1 = (x - x0)**2 + (y - y0)**2 - r**2 f_2 = (x - x1)**2 + (y - y1)**2 - r**2 result = solve_poly_system([f_1, f_2], x, y) assert len(result) == 2 and all(len(r) == 2 for r in result) assert all(len(r.find(query)) == 1 for r in flatten(result))
def test_solve_biquadratic(): x0, y0, x1, y1, r = symbols('x0 y0 x1 y1 r') f_1 = (x - 1)**2 + (y - 1)**2 - r**2 f_2 = (x - 2)**2 + (y - 2)**2 - r**2 assert solve_poly_system([f_1, f_2], x, y) == \ [(S(3)/2 + (-1 + 2*r**2)**(S(1)/2)/2, S(3)/2 - (-1 + 2*r**2)**(S(1)/2)/2), (S(3)/2 - (-1 + 2*r**2)**(S(1)/2)/2, S(3)/2 + (-1 + 2*r**2)**(S(1)/2)/2)] f_1 = (x - 1)**2 + (y - 2)**2 - r**2 f_2 = (x - 1)**2 + (y - 1)**2 - r**2 assert solve_poly_system([f_1, f_2], x, y) == \ [(1 + (-((1 - 2*r)*(1 + 2*r)))**(S(1)/2)/2, S(3)/2), (1 - (-((1 - 2*r)*(1 + 2*r)))**(S(1)/2)/2, S(3)/2)] query = lambda expr: expr.is_Pow and expr.exp is S.Half f_1 = (x - 1 )**2 + (y - 2)**2 - r**2 f_2 = (x - x1)**2 + (y - 1)**2 - r**2 result = solve_poly_system([f_1, f_2], x, y) assert len(result) == 2 and all(len(r) == 2 for r in result) assert all(r.count(query) == 1 for r in flatten(result)) f_1 = (x - x0)**2 + (y - y0)**2 - r**2 f_2 = (x - x1)**2 + (y - y1)**2 - r**2 result = solve_poly_system([f_1, f_2], x, y) assert len(result) == 2 and all(len(r) == 2 for r in result) assert all(len(r.find(query)) == 1 for r in flatten(result))
def test_Domain_map(): seq = ZZ.map([1, 2, 3, 4]) assert all([ ZZ.of_type(elt) for elt in seq ]) seq = ZZ.map([[1, 2, 3, 4]]) assert all([ ZZ.of_type(elt) for elt in seq[0] ]) and len(seq) == 1
def test_Domain_map(): seq = ZZ.map([1, 2, 3, 4]) assert all([ZZ.of_type(elt) for elt in seq]) seq = ZZ.map([[1, 2, 3, 4]]) assert all([ZZ.of_type(elt) for elt in seq[0]]) and len(seq) == 1