Calculating union of two sets of reals

Given the following two sets of reals:

-(1/4) < x <= 0 || 0 < x <= 1/2 || x > 1/2
x <= -1 || -1 < x < 0


how can I calculate their union? The expected answer is:

0 > x > -1/4

• The union is all real numbers. The intersection gives the expected answer, but it's not the only way to get the expected answer. Please clarify the question. Commented Aug 16, 2023 at 13:07

You can try

Reduce[{-(1/4) < x <= 0 || 0 < x <= 1/2 || x > 1/2}, x]


x > -(1/4)

Reduce[{x <= -1 || -1 < x < 0}, x]


x < 0

set1 = Reduce[{-(1/4) < x <= 0 || 0 < x <= 1/2 || x > 1/2}]
set2 = Reduce[{x <= -1 || -1 < x < 0}]
Reduce[set1 && set2, x]


-(1/4) < x < 0

• In[534]:= Clear["Global*"] f[x_] := Piecewise[{{2^-x, x <= 0}, {1, x > 0}}] Reduce@Reduce[f[x + 1] < f[2 x], x, Reals] Out[536]= x < 0The results not merged above come from the solution set of inequalities Commented Aug 15, 2023 at 5:59
• Is it still nested with a layer of reduce? Commented Aug 15, 2023 at 5:59
• See updated. Some thing like that? Commented Aug 15, 2023 at 6:06
Simplify[(-(1/4) < x <= 0 || 0 < x <= 1/2 || x > 1/2) && (( x <= -1 || -1 < x < 0))]

(*  -(1/4) < x < 0 *)


Laurenso's answer is how I'd normally do it, but let me also offer the following:

RegionIntersection[ImplicitRegion[-(1/4) < x <= 0 || 0 < x <= 1/2 || x > 1/2, {x}],
ImplicitRegion[x <= -1 || -1 < x < 0, {x}]]
ImplicitRegion[-(1/4) < x < 0, {x}]


You can just combine (as @Laurenso, which I have voted for)

w = (-(1/4) < x <= 0 || 0 < x <= 1/2 || x > 1/2) &&
(x <= -1 || -1 < x < 0);
Reduce[w, x]


yields: 1/4 < x < 0

Interval[]: is closed intervals but for illustrative purposes:

i1 = Interval[{-1/4, 0}];
i2 = Interval[{0, 1/2}];
i3 = Interval[{1/2, Infinity}];
i4 = Interval[{-Infinity, -1}];
i5 = Interval[{-1, 0}];
i8 = IntervalIntersection[i6 = IntervalUnion[i1, i2, i3],
i7 = IntervalUnion[i4, i5]];
NumberLinePlot[{i1, i2, i3, i4, i5, i6, i7, i8},
PlotLegends -> "Expressions"]


• What is differrent between '-1/4 <x<0' and -1/4<=x<=0 when I use 'NumLinePlot'? Commented Aug 16, 2023 at 23:38
• I just wanted illustrate Interval functions. I think NumberLinePlot uses open circles for open interval but am not near computer at present Commented Aug 17, 2023 at 1:01
Simplify[-(1/4) < x <= 0 || 0 < x <= 1/2 || x > 1/2]


1 + 4 x > 0`