Solving for intervals without using NumberLinePlot

I’ve been struggling to find a way to find an interval solution to an equation/inequality. I know mathematica can do this since for example,

NumberLinePlot[Sin[x] < 0.5, {x, 0, 6.28}] gives a plot of the correct interval. How can I have mathematica just give me the Interval instead of the plot? =================      Like this? Reduce[0 <= x <= 2 \[Pi] && Sin[x] < 1/2, x]. The || symbol means Or. – march Nov 1 '15 at 5:41      Reduce[Sin[x] < 1/2 && 0 < x < 2 Ï€, x] gives 0 < x < Ï€/6 || (5*Ï€)/6 < x < 2*Ï€. The || march refers is in the result. – m_goldberg Nov 1 '15 at 5:47      Ah ok, thanks march and goldberg! Does mathematica have a built in function to convert the result into intervals? I can write a (sloppy) function for it myself but I'd rather use built-in functions. – ra91 Nov 1 '15 at 5:58 ================= 2 Answers 2 ================= You might try List @@ (Drop[#, {2, -2}]& /@ List @@@ Reduce[Sin[x] < 1/2 && 0 < x < 2 Ï€, x]) {{0, Ï€/6}, {(5 Ï€)/6, 2 Ï€}} Note that foo = Reduce[{ Sin[x] < 1/2, 0 <= x <= 2 Ï€ }, x, Reals] (* 0 <= x < Ï€/6 || (5 Ï€)/6 < x <= 2 Ï€ *) almost gives you what you want. We can rewrite this to be in interval form, ineqsToIntervals[x_Or] := List @@ ( x /. { Inequality[a_, Less, _, Less, b_] :>
Row[{“(“, a, “,”, b, “)”}],
Inequality[a_, LessEqual, _, Less, b_] :>
Row[{“[“, a, “,”, b, “)”}],
Inequality[a_, Less, _, LessEqual, b_] :>
Row[{“(“, a, “,”, b, “]”}],
Inequality[a_, LessEqual, _, LessEqual, b_] :>
Row[{“[“, a, “,”, b, “]”}]
}
)

so that ineqsToIntervals[foo] gives {[0,π6),(5π6,2π]}\{ [0,\frac{\pi}{6}), (\frac{5\pi}{6},2\pi] \}.

1

 

Note: you do not need to specify the domain to Reduce. The inequality 0 <= x <= 2 Ï€ is sufficient to tell Reduce it is working over the reals. – m_goldberg Nov 1 '15 at 6:20      Awesome, thanks! – ra91 Nov 1 '15 at 6:31