# Is there a way to find the values of x for a graph in a given area?

Sorry for my wording, I'm not sure what the proper term for this is. I want to find the sections of x for which the graph of some function, f(x), is in a given area. For an example of what I'm describing, I want to know how to find the thick black bars in the picture below.

-
Is this question about the software Mathematica? – Yves Klett Jan 31 at 20:58
It is. Again sorry for my wording. I wanted to know if there was a function or some other way to do this in Mathematica. – harpreet bains Jan 31 at 21:14
...is that mac os 7? – Sascha Jan 31 at 22:45

Use Reduce to get the region as inequalities:

f[x_] := Sin[4 x] + x;
Reduce[-1 <= f[x] <= 1, x, Reals]

(* Root[{1 + Sin[4 #1] + #1 &, -1.45320652256538767403}] <= x <=
Root[{1 + Sin[4 #1] + #1 &, -0.71249223361378546370}] ||
Root[{1 + Sin[4 #1] + #1 &, -0.222621770186095002502}] <= x <=
Root[{-1 + Sin[4 #1] + #1 &, 0.222621770186095002502}] ||
Root[{-1 + Sin[4 #1] + #1 &, 0.71249223361378546370}] <= x <=
Root[{-1 + Sin[4 #1] + #1 &, 1.45320652256538767403}] *)


With recently introduced NumberLinePlot it can also be visualized easily. Most of the code below is really styling for aesthetics...

Module[{f},
f[x_] := Sin[4 x] + x;
Show[{Plot[{f[x], -1, 1}, {x, -2, 2},
PlotStyle -> {Automatic, Gray, Gray}, Filling -> {2 -> {3}}],
NumberLinePlot[Reduce[-1 <= f[x] <= 1, x, Reals], x, Spacings -> 0,
PlotStyle -> Thickness[0.008]]}]]


EDIT: If you're looking only for the visualization, it's actually possible to skip Reduce entirely inside NumberLinePlot and pass the specification (-1 <= f[x] <= 1) directly to it. Extra Reduce doesn't hurt, though...

-
Thank you so much, this is exactly what I was looking for. – harpreet bains Jan 31 at 21:18