There are two subproblems: finding a reasonable plot range and restricting the graph to a subset of that range.
The following is somewhat brute force, but it is clear and general. It begins in the same way, by defining the function to plot (because it will be invoked several times):
f[x_] := (x^2 + 1)/x
We will also invoke the constraints twice, so let's put them into a function, too:
g[x_] := f[x]^2 > 4 && f[x]^3 < 64
(Reduce
could be used here to speed up future calls to g
, but it is not necessary. In other cases Reduce
could fail to find a solution, so avoiding it provides a more general approach to plotting.)
We use numerical methods to find a finite plotting interval because there's no point to getting exact symbolic solutions for a plot. The idea is to maximize and minimize $x$ subject to the constraints, but limiting the search to an interval to make sure that finite endpoints are obtained:
xlim = x /. Last[#[{x, g[x], -10 <= x <= 10}, x]] & /@ {NMinimize, NMaximize}
Assemble this information into the plot:
Plot[If[g[x], f[x]], Evaluate @ {x, Sequence @@ xlim}]
In principle, the left limit of this plot should be $-\infty$; it was truncated at $-10$ by the interval constraints provided to NMaximize
and NMinimize
. Without that truncation the plot could not be created.