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
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
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 < 0
The results not merged above come from the solution set of inequalities
$\endgroup$
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"]
Simplify[-(1/4) < x <= 0 || 0 < x <= 1/2 || x > 1/2]
1 + 4 x > 0