4

Mathematica provides functions to test whether a number is an integer, even or odd, prime, rational, real or complex. However, I could not find any explicit way to determine whether a number is irrational, or more precisely transcendental.

For instance, Alpha provides a means of determining such properties by simply asking:

is pi transcendental?

which will return "true" or "false". However, I could not find any matching function in Mathematica. Any suggestions?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Klangen
  • 1,009
  • 5
  • 14

2 Answers2

9

We can use RootApproximant and PossibleZeroQ to guess if a number is algebraic or not.

PossibleAlgebraic[x_] := 
  With[{res = Element[x, Algebraics]},
    res /; BooleanQ[res]
  ]

PossibleAlgebraic[x_?NumericQ] /; !InexactNumberQ[x] := 
  With[{guess = RootApproximant[x]},
    Quiet[PossibleZeroQ[x - guess]] /; Element[guess, Algebraics]
  ]

PossibleAlgebraic[_?NumericQ] = False;

Some tests:

PossibleAlgebraic[Sqrt[2]]
True
PossibleAlgebraic[HypergeometricPFQ[{1/5, 2/5, 3/5, 4/5}, {1/2, 3/4, 5/4}, 3125/256]]
True
PossibleAlgebraic[π]
False
PossibleAlgebraic[EulerGamma]
False
Greg Hurst
  • 35,921
  • 1
  • 90
  • 136
8
istranscendental[x_] := ! Element[x, Algebraics]

To the extent that Mathematica is aware of the algebraic numbers, this should work. EulerGamma, for example, is returned unevaluated, while Pi returns True and 2 returns False.

eyorble
  • 9,383
  • 1
  • 23
  • 37
  • 4
    This works for simple cases, but is not completely foolproof. As an example, the expression HypergeometricPFQ[{1/5, 2/5, 3/5, 4/5}, {1/2, 3/4, 5/4}, 3125/256] is a root of the polynomial $$x^5-x+1$$ but feeding this expression into this test will yield an unevaluated result. – J. M.'s missing motivation Mar 06 '18 at 00:07
  • @J.M. Thank you - do you have a better solution? If so, I would be happy to accept it. – Klangen Mar 06 '18 at 08:35
  • @Pickle, I do not; that is why I was giving it as a cautionary tale. – J. M.'s missing motivation Mar 06 '18 at 08:37
  • Then it looks like the free Alpha has a feature that its expensive brother does not have? – Klangen Mar 06 '18 at 09:42
  • 1
    @Pickle http://www.wolframalpha.com/input/?i=is+HypergeometricPFQ%5B%7B1%2F5,+2%2F5,+3%2F5,+4%2F5%7D,+%7B1%2F2,+3%2F4,+5%2F4%7D,+3125%2F256%5D+transcendental Wolfram|Alpha doesn't know that one either. – eyorble Mar 06 '18 at 09:46