def get_covering_intervals(rectangle, polynomial):
crossing_points = []
# Find crossing points
for line, x_range in get_lines_from_rectangle(rectangle):
roots = solve_polynomial(polynomial-line)
for root in roots:
if x_range.min < root < x_range.max:
crossing_points.append(root)
crossing_points.extend(rectangle.x_range)
crossing_points.sort()
# Find covered areas
covered_intervals = []
prev_x = crossing_points[0]
for x in crossing_points[1:]:
if polynomial((x+prev_x)/2) in rectangle:
covered_intervals.append(Interval(prev_x, x))
prev_x = x
return covered_intervals
polynomial = Polynomial([10, 2, 4]) # 10x^2+2x+4
definition_area = Interval(-1.5, 2.5)
rectangles = [Rectangle((-1.25, -1), (1, 1.25), (1.25, 1), (-1, -1.25)), ...]
covered_intervals = []
for rectangle in rectangles:
covered_intervals.extend(get_covering_intervals(rectangle, polynomial))
covered = union(covered_intervals)
return definition_area in covered