Check if number is irrational/transcendental
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
.
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