# Strange RegionDifference output on simple example

Why is the output so irregular in the following simple example?

Region[RegionDifference[
Rectangle[{-2, -1}, {5, 1}],
RegionUnion[Disk[{0.5, 0}, 0.25], Disk[{3.5, 0}, 0.25]]
]]


I'm using MMA 12.1 on Windows.

• What's displayed is a quick representation of the region. To get a high quality plot, use RegionPlot or DiscretizeRegion. Nov 14 '21 at 14:02

This irregularity only appears in the visualization from the Region wrapper. Under the hood the region is still exactly intact:

reg = RegionDifference[Rectangle[{-2, -1}, {5, 1}],
RegionUnion[Disk[{0.5, 0}, 0.25], Disk[{3.5, 0}, 0.25]]];

Area[Rationalize[reg]]

14 - π/8


Most likely Region is using a general method like marching squares to visualize this region:

BoundaryDiscretizeRegion[reg, Method -> "MarchingSquares"]


• Yep, more or less: Trace[ MakeBoxes[#, StandardForm] &[reg], _BoundaryDiscretizeRegion, TraceInternal -> True ] Nov 14 '21 at 14:03
DiscretizeRegion[#
, AccuracyGoal -> 3
, PerformanceGoal -> "Speed"
(*,Method\[Rule]"Continuation"*)
] &@RegionDifference[Rectangle[{-2, -1}, {5, 1}],
RegionUnion[Disk[{0.5, 0}, 0.25], Disk[{3.5, 0}, 0.25]]]


• AccuracyGoal can be set to 2 to get good enough circles. A value such as 10 locks my computer up but that could be due to many reasons.
• Method->"Continuation" (without the accuracy goal) also delivers good results for this case while maintaining good response time.

A one more way is as follows.

RegionPlot[RegionDifference[Rectangle[{-2, -1}, {5, 1}],
RegionUnion[Disk[{0.5, 0}, 0.25], Disk[{3.5, 0}, 0.25]]], AspectRatio -> 2/7]