NumericQ
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 all close allBasic Examples (1)
Scope (2)
An object is numeric if all its constituents are numeric:
expr = BesselJ[2, Sin[Exp[Log[3] + 4]] + x];NumericQ[expr]Some parts of the expression are numeric:
TableForm[Map[{#, NumericQ[#]}&, Level[expr, {0, Infinity}]], TableHeadings -> {{}, {"e", "NumericQ[e]"}}]The system symbols that represent numerical constants:
ssymb = Names["System`*"];constants = Select[ssymb, MemberQ[Attributes[#], Constant] && FreeQ[Attributes[#], NumericFunction]&]Some of the system symbols with the NumericFunction attribute:
nfuns = RandomSample[Select[ssymb, MemberQ[Attributes[#], NumericFunction]&], 30]Any combination of these functions with numeric arguments will be numeric:
e = Quiet[Nest[RandomChoice[ToExpression /@ nfuns][RandomChoice[ToExpression /@ constants], #]&, 1, 10]]NumericQ[e]In most cases, N[e] will not be a number since it is improbable that the arguments are correct:
NumberQ[Quiet[N[e]]]Applications (3)
Test if a matrix consists of numeric entries:
m = {{Cos[1], Sin[1]}, {-Sin[1], Cos[1]}};MatrixQ[m, NumericQ]Define a function that only evaluates when its argument is numeric:
f[a_ ? NumericQ] := Module[{g, x}, Quiet[g[x_] = x ^ 2 + x + a;r = x /. FindRoot[g[x], {x, 1}];If[Abs[g[r]] < 10 ^ -4, r, x /. FindRoot[g[x], {x, 1 + I}]]]]f[a]f[Sqrt[2]]Plot[{Re[f[a]], Im[f[a]]}, {a, -2, 2}]Define a function that has a special case for numeric arguments:
f[x_ ? NumericQ, prec_ : MachinePrecision] := N[x, prec]f[x_] := FullSimplify[x]f[Exp[1] + Exp[-1]]f[Exp[x] + Exp[-x]]Properties & Relations (3)
If NumberQ[x] is True, then NumericQ[x] is also True:
TableForm[Table[{x, NumberQ[x], NumericQ[x]}, {x, {1, 3 / 2, 1.5, 1 + I, E, Sin[1], Underflow[], Overflow[], Infinity}}], TableHeadings -> {{}, {"x", "NumberQ", "NumericQ"}}]When f has the NumericFunction attribute, then f[args] is numeric when args are numeric:
SetAttributes[f, NumericFunction]NumericQ[f[Pi, Sin[1 + I]]]NumericQ will give True for numerical expressions that may produce real or complex values:
nums = {ArcSin[1 / 2], ArcSin[3 / 2]};
NumericQ /@ numsOnly one of these two values is real:
nums//NUse RealValuedNumericQ to test for numeric expressions that are real valued.
RealValuedNumericQ /@ numsPossible Issues (1)
NumericQ[e] does not always imply that N[e] will yield a number:
e = 1 / (Sin[1] ^ 2 + Cos[1] ^ 2 - 1)NumericQ[e]SetPrecision[e, 20]NumberQ[%]This can also happen when the arguments for the function are given incorrectly:
e = Sin[1, 2]NumericQ[e]NumberQ[N[e]]Tech Notes
Related Guides
History
Introduced in 1996 (3.0)
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_2026_numericq, author="Wolfram Research", title="{NumericQ}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/NumericQ.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_numericq, organization={Wolfram Research}, title={NumericQ}, year={1996}, url={https://reference.wolfram.com/language/ref/NumericQ.html}, note=[Accessed: 12-June-2026]}