is an attribute that can be assigned to a symbol f to indicate that f[arg1,arg2,…] should be considered a numeric quantity whenever all the argi are numeric quantities.
NumericFunction
is an attribute that can be assigned to a symbol f to indicate that f[arg1,arg2,…] should be considered a numeric quantity whenever all the argi are numeric quantities.
Details
- Most standard built‐in mathematical functions have the attribute NumericFunction.
- NumericQ checks the NumericFunction attribute of every function it encounters.
- If you assign the attribute NumericFunction to a function that does not yield numerical values, then NumericQ will give misleading results. »
Examples
open all close allBasic Examples (1)
Log has the NumericFunction attribute:
Attributes[Log]When Log has an argument that is a number, constant, or numeric, the result is numeric:
NumericQ[Log[2]]In most cases when NumericQ[expr] gives True, then N[expr] yields an explicit number:
N[Log[2]]Scope (1)
Define f to be a numeric function:
SetAttributes[f, NumericFunction]If you have not assigned f to yield numerical values, then NumericQ gives misleading results:
NumericQ[f[2]]N[f[2]]Assign f to evaluate for arguments that are approximate numbers:
f[x_ ? InexactNumberQ] := Precision[x] - Accuracy[x]N[f[2]]Applications (2)
Consider the following two function definitions, where one has the NumericFunction attribute:
SetAttributes[f1, NumericFunction];
f1[x_ ? InexactNumberQ] := Log[x]
f2[x_ ? InexactNumberQ] := Log[x]Define a function
that evaluates faster for numeric input than for arbitrary input:
g[x_ ? NumericQ] := N[x] ^ 2
g[x_] := (Pause[1];N[x] ^ 2)The evaluation of
is faster when it is able to recognize that its argument can be treated as numeric:
AbsoluteTiming[g[f1[1]]]AbsoluteTiming[g[f2[1]]]Define a function that can represent an exact value:
SetAttributes[f, NumericFunction];Assign N[f[a]] to give the derivative with respect to a of the solution of an ODE at
:
N[f[a_], {prec_, acc_}] := Block[{x, t, xa, wp = If[prec == MachinePrecision, prec, 2 * prec]}, First[xa[1] /. NDSolve[{x''[t] + Sin[a x[t]] == 0, xa''[t] + x[t]Cos[a x[t]] == 0, x[0] == 1, x'[0] == xa[0] == xa'[0] == 0}, {x, xa}, {t, 0, 1}, WorkingPrecision -> wp, Method -> "Extrapolation"]]]Assign f for approximate numbers:
f[a_ ? InexactNumberQ] := Block[{x, t, xa}, First[xa[1] /. NDSolve[{x''[t] + Sin[a x[t]] == 0, xa''[t] + x[t]Cos[a x[t]] == 0, x[0] == 1, x'[0] == xa[0] == xa'[0] == 0}, {x, xa}, {t, 0, 1}, WorkingPrecision -> Precision[a], Method -> "Extrapolation"]]]f[1] does not evaluate but represents a number:
{f[1], NumericQ[f[1]]}N[f[1]]It will work with any precision (within reasonable limits!):
N[f[1], 32]Plot[f[a], {a, 0, 10}]Properties & Relations (2)
Sin has the attribute NumericFunction:
Attributes[Sin]The NumericFunction attribute informs NumericQ that Sin[1] can be converted into a number when using N:
NumberQ[N[Sin[1]]]NumericQ can return True without having to evaluate N[Sin[1]]:
NumericQ[Sin[1]]Note that NumberQ returns False:
NumberQ[Sin[1]]Some of the system symbols that are numeric functions:
RandomSample[Select[Names["System`*"], MemberQ[Attributes[#], NumericFunction]&], 10]Tech Notes
Related Guides
History
Introduced in 1996 (3.0)
Text
Wolfram Research (1996), NumericFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/NumericFunction.html.
CMS
Wolfram Language. 1996. "NumericFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NumericFunction.html.
APA
Wolfram Language. (1996). NumericFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NumericFunction.html
BibTeX
@misc{reference.wolfram_2026_numericfunction, author="Wolfram Research", title="{NumericFunction}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/NumericFunction.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_numericfunction, organization={Wolfram Research}, title={NumericFunction}, year={1996}, url={https://reference.wolfram.com/language/ref/NumericFunction.html}, note=[Accessed: 12-June-2026]}