Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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 ?

share|improve this question
1  
This answer should be helpful mathematica.stackexchange.com/questions/10388/… –  Artes Mar 19 '13 at 10:26
    
Yes, it is. Thank you. –  Massimo Cafaro Mar 19 '13 at 12:00
add comment

1 Answer

up vote 7 down vote accepted

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[20], 3], ImageSize -> 500,BoxRatios -> 1,
  RegionFunction -> Function[{m, k, c}, 
   m (k - 1) + (k - 2) < c k && m >= 2 && k >= 2 && c >= 1] ]

enter image description here


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[1], Red, Point@eq}] 

enter image description here

ListPointPlot3D[{eq, better, worse}, 
  PlotStyle -> {Directive[PointSize[.02], Red], Blue, Green}, BoxRatios -> 1]

enter image description here

share|improve this answer
    
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. –  kguler Mar 19 '13 at 12:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.