Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have found no way to define the domain of Irrational numbers. I can easily define a test to see if a number is irrational by defining:

IrrationalQ[z_] := Element[z, Reals] && ! Element[z, Rationals]

IrrationalQ /@ Sqrt /@ Range[10]    
{False, True, True, False, True, True, True, True, False, True}

My question is how can I define a domain that would work with Element, something like

Element[Sqrt[2], Irrationals]

I am aware that the documentation list possible domains as Booleans, Complexes, Integers, Primes, Rationals, Reals, but it is not clear to me if that list is exclusive or not.

share|improve this question
@Ymareth your very small edit got accepted, in part by me (because I forgot that my vote alone was not enough). Of course it is nice to have a good title, but please do not suggest edits that are too small. You can read about this on meta – Jacob Akkerboom Feb 12 '14 at 14:58
up vote 5 down vote accepted

Here's another way, using TagSetDelayed:

Irrationals /: Element[x_, Irrationals] := 
  Element[x, Reals] && ! Element[x, Rationals];

Element[Sqrt[2], Irrationals]

This should work for elementary calculation. However, I don't think there is way to fully incorporate Irrationals as a domain into Mathematica (e.g., into Reduce[expr, vars, domain] or Solve). Note also that the predicate

Element[x, Reals] && ! Element[x, Rationals];

does not evaluate to True or False with approximate numbers (obviously, perhaps) and that algorithms that use numeric heuristics might be unreliable or simply be bypassed.

(I suspect that the domain is used in most cases to choose an algorithm. The standard domains are what they are because so much work over the centuries has gone into developing algorithms for them.)

share|improve this answer

You are almost there:

Element[x_, Irrationals] := Element[x, Reals] && ! Element[x, Rationals];

Sqrt[2] \[Element] Irrationals
share|improve this answer
I was not aware at all of the ability to Unprotect. Thanks so much! – rhermans Feb 12 '14 at 12:37

Your Answer


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.