0
$\begingroup$

Is there an attribute for symbols that makes NumericQ give True? For example Pi and E are symbols that behave this way, but I can't figure out which attribute to give it.

NumericFunction works well provided the symbol takes at least one argument:

SetAttributes[f,NumericFunction]


NumericQ[f]
(*False   <--- I want this to be true*)

NumericQ[f[1]]
(*True*)

But I need something for just symbols.

$\endgroup$

1 Answer 1

1
$\begingroup$

I'm not sure if this is the official way to do it, but at least in 8.0.0.0 you can simply assign it:

NumericQ[f] = True

For example:

N[twopi, n_] := N[2*Pi, n]
NumericQ[twopi] = True
{twopi, twopi > 1}
(*
==> {twopi, True}
*)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.