RegionIntersection not returning what I expected
Region-combination functions such as RegionIntersection
call BooleanRegion
to compute the result. For instance,
RegionIntersection[reg1, reg2,…]
is equivalent to BooleanRegion[And, {reg1, reg2,…}]
In turn, BooleanRegion
seems to apply some basic logic to eliminate unnecessary computation. The following and their equivalent RegionIntersection
calls return region
without inspecting, simplifying, or otherwise altering region
:
BooleanRegion[And, {region}]
BooleanRegion[And, {region, region}] (* DeleteDuplicates[] is used to remove copies *)
BooleanRegion[And, {region, FullRegion[n]}] (* where n is the dimension of region *)
Possible workarounds include intersecting region
with a region distinct from region
and FullRegion[n]
that covers region
. Simply specifying a full region as an ImplicitRegion
or changing the variables in region
suffice. Unfortunately Simplify[ImplicitRegion[..]]
does nothing. In this case, if we apply Simplify
or Reduce
to the first argument gets around this.
ireg = ImplicitRegion[x < 0 && x > 0, {x}]
yreg = ireg /. x -> y (* change variable *)
fullreg = ImplicitRegion[-Infinity < x < Infinity, {x}] (* a disguised full region *)
(*
ImplicitRegion[x < 0 && x > 0, {x}]
ImplicitRegion[y < 0 && y > 0, {y}]
ImplicitRegion[-∞ < x < ∞, {x}]
*)
RegionIntersection[ireg, yreg]
RegionIntersection[ireg, fullreg]
(*
EmptyRegion[1]
EmptyRegion[1]
*)
Simplification:
MapAt[Simplify, ireg, 1]
MapAt[Reduce, ireg, 1]
(*
EmptyRegion[1]
EmptyRegion[1]
*)
It seems Mathematica is missing a RegionSimplify
or RegionReduce
function. At least, I didn't find one.