NumericQ

NumericQ[expr]

gives True if expr is a numeric quantity, and False otherwise.

Details

  • An expression is considered a numeric quantity if it is either an explicit number or a mathematical constant such as Pi, or is a function that has attribute NumericFunction and all of whose arguments are numeric quantities.
  • In most cases, NumericQ[expr] gives True whenever N[expr] would yield an explicit number.

Examples

open allclose all

Basic Examples  (1)

NumericQ tests whether an object is a numeric quantity:

In most cases, NumericQ[expr] gives True whenever N[expr] yields an explicit number:

Scope  (3)

An object is numeric if all its constituents are numeric:

Some parts of the expression are numeric:

When f has the NumericFunction attribute then f[args] is numeric when args are numeric:

The system symbols that represent numerical constants:

Some of the system symbols with the NumericFunction attribute:

Any combination of these functions with numeric arguments will be numeric:

In most cases, N[e] will not be a number since it is improbable that the arguments are correct:

Applications  (3)

Test if a matrix consists of numeric entries:

Define a function that only evaluates when its argument is numeric:

Define a function that has a special case for numeric arguments:

Possible Issues  (1)

NumericQ[e] does not always imply that N[e] will yield a number:

This can also happen when the arguments for the function are given incorrectly:

Wolfram Research (1996), NumericQ, Wolfram Language function, https://reference.wolfram.com/language/ref/NumericQ.html.

Text

Wolfram Research (1996), NumericQ, Wolfram Language function, https://reference.wolfram.com/language/ref/NumericQ.html.

CMS

Wolfram Language. 1996. "NumericQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NumericQ.html.

APA

Wolfram Language. (1996). NumericQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NumericQ.html

BibTeX

@misc{reference.wolfram_2024_numericq, author="Wolfram Research", title="{NumericQ}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/NumericQ.html}", note=[Accessed: 21-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_numericq, organization={Wolfram Research}, title={NumericQ}, year={1996}, url={https://reference.wolfram.com/language/ref/NumericQ.html}, note=[Accessed: 21-December-2024 ]}