3

Example:

S = {r ∈ Q : r² < 2}

Let S be the set of all rational numbers whose squares are less than 2. It follows that 1 ∈ S, 4/3 ∈ S, but 3/2 doesn't ∈ S because 9/4 ≥ 2.

Thank you.

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
Luiz Meier
  • 519
  • 4
  • 9
  • 1
    I don't believe Mathematica has the ability to represent an infinite set in that fashion. You may find this useful however: (838). Depending on what you are doing you may also be able to give the conditions to Reduce or FindMinimum, etc., if searching for a particular value or range of values. Could you give some examples of what you are actually trying to accomplish? – Mr.Wizard Sep 18 '14 at 05:13
  • 1
    @Mr.Wizard I'm trying to represent an infinite set as you said. Later, I would create, say, two more sets with a diff rule and then use the usual union/intersection (set operations). Maybe I use, instead, a plain function (with conditionals, say, IF something...). Would be nice to be able to use the Union / Intersection commands indeed. – Luiz Meier Sep 18 '14 at 06:01

1 Answers1

5

You can use ImplicitRegion to define this type of set.

Define your set.

\[ScriptCapitalR] = ImplicitRegion[r \[Element] Rationals && r^2 < 2, {r}];

Check that this works correctly on some rational and some irrational points.

Element[#, \[ScriptCapitalR]] & /@ {{1}, {4/3}, {3/2}, {\[Pi]}, {E}}

(* {True, True, False, False, False} *)

Define a larger set.

\[ScriptCapitalS] = ImplicitRegion[r \[Element] Rationals && r^2 < 3^2, {r}];

Compute the difference between the above 2 sets -- this is an "annular" region.

\[ScriptCapitalS]minus\[ScriptCapitalR] = RegionDifference[\[ScriptCapitalS], \[ScriptCapitalR]];

Check that this works correctly on some rational and some irrational points.

Element[#, \[ScriptCapitalS]minus\[ScriptCapitalR]] & /@ {{1}, {4/3}, {3/2}, {\[Pi]}, {E}}

(* {False, False, True, False, False} *)
Stephen Luttrell
  • 5,044
  • 1
  • 19
  • 18