# How to plot inequalities taking into account that points must be integers and not reals?

I have solved with Mathematica 9 the following integer inequalities using Reduce:

eq = Reduce[
m (k - 1) + (k - 2) == c k && m >= 2 && k >= 2 && c >= 1, {k, m,
c}, Integers, Backsubstitution -> True]

(* (k | m | c) \[Element] Integers && k >= 2 && m >= 2 &&
c == (-2 + k - m + k m)/k *)

better = Reduce[
m (k - 1) + (k - 2) <  c k && m >= 2 &&  k >= 2 && c >= 1, {k, m,
c}, Integers, Backsubstitution -> True]

(* (c \[Element] Integers && k == 2 && m == 2 &&
c >= 2) || ((m | c) \[Element] Integers && k == 2 && m >= 3 &&
c > m/2) || ((k | m | c) \[Element] Integers && k >= 3 && m >= 2 &&
c > (-2 + k - m + k m)/k) *)

worst = Reduce[
m (k - 1) + (k - 2) >  c k && m >= 2 &&  k >= 2 && c >= 1 , {k, m,
c}, Integers, Backsubstitution -> True]

(* ((m | c) \[Element] Integers && k == 2 && m >= 3 &&
1 <= c < m/2) || ((k | m | c) \[Element] Integers && k >= 3 &&
m >= 2 && 1 <= c < (-2 + k - m + k m)/k) *)


Now I need to plot them. However, using RegionPlot3D I can only plot a region made of reals, while the solutions are integers. What is the proper way to plot the solutions when the domain is Integers ?

Update: you can use your conditions to define the RegionFunction in ListPointPlot3D without having to use Reduce. For example, for the set better:

 ListPointPlot3D[Tuples[Range, 3], ImageSize -> 500,BoxRatios -> 1,
RegionFunction -> Function[{m, k, c},
m (k - 1) + (k - 2) < c k && m >= 2 && k >= 2 && c >= 1] ] You can use Graphics3D or ListPointPlot3D using all the integer solutions that lie in the plot range of your choice:

dom =0 <= k <= 20 && 0 <= m <= 20 && 0 <= c <= 20; (* this plays the role of PlotRange *)
eq = Last /@ # & /@ {ToRules[
Reduce[m (k - 1) + (k - 2) == c k && m >= 2 && k >= 2 && c >= 1 && dom,
{k, m, c}, Integers, Backsubstitution -> True]]};
better = Last /@ # & /@ {ToRules[
Reduce[m (k - 1) + (k - 2) < c k && m >= 2 && k >= 2 && c >= 1 && dom,
{k, m, c}, Integers, Backsubstitution -> True]]};
worse = Last /@ # & /@ {ToRules[
Reduce[m (k - 1) + (k - 2) > c k && m >= 2 && k >= 2 && c >= 1 && dom,
{k, m, c}, Integers, Backsubstitution -> True]]};
Graphics3D[{PointSize[.02], Opacity[.3], Blue, Point@better, Green,
Point@worse, Opacity, Red, Point@eq}] ListPointPlot3D[{eq, better, worse},
PlotStyle -> {Directive[PointSize[.02], Red], Blue, Green}, BoxRatios -> 1] • Great answer. Thank you very much for spending your time answering; I learned a lot about visualization in Mathematica today. – Massimo Cafaro Mar 19 '13 at 11:58
• @Massimo, my pleasure. – kglr Mar 19 '13 at 12:08