2
$\begingroup$

The following expressions give True in the NumericQ test:

Map[NumericQ, {Rational[2, 3], Complex[2, 3], Root[1 + 2 #1 + #1^5 &, 1], RootSum[-7 - 3 #1 + #1^5 &, Sin[#1] &]}] (* Out: {True, True, True, True} *) 

However the heads Rational, Complex, Root and RootSum do not have the attribute NumericFunction:

Attributes[Root] (* Out: {NHoldAll, Protected, ReadProtected} *) 

... but NumericQ still returns True when applied to them.

Is there a way to obtain a list of all the possible heads h of expressions h[args] that do NOT have the NumericFunction attribute, and yet will give True in the test NumericQ[h[args]]?

$\endgroup$
0

1 Answer 1

4
$\begingroup$

Note that Root is only considered numeric when its argument does NOT contain any non-numerical parameters. For instance:

Root[(# - a) &, 1] (* Out: a *) NumericQ@Root[(# - a) &, 1] (* Out: False *) 

A similar argument applies to RootSum, Rational, and Complex:

NumericQ@RootSum[a + # &, Log[#1] &] (* False *) NumericQ@Rational[a, 2] (* False *) NumericQ@Complex[a, 2] (* False *) 

It seems to me that these examples still fall within the general guideline presented in the documentation for NumericQ, under "Details": "NumericQ[expr] gives True whenever N[expr] would yield an explicit number".

$\endgroup$
1
  • $\begingroup$ Yes they do fall within the documentation, what I want to know is the explicit list of ALL the heads that fall within the documentation, I know Root, RootSum, Rational, Complex, are there others? Could new ones appear in future versions of Mathematica? If so, how could they be automatically detected in the code of a Mathematica package? $\endgroup$ Commented Jun 9, 2016 at 21:58

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.