Good Practice in Defining Numeric Functions
You mainly need NumericFunction
attribute. You may also need Listable
attribute that many numeric functions own:
ClearAll@f
SetAttributes[f, {NumericFunction, Listable}]
f[x_ /; Precision[x] != Infinity] :=
NIntegrate[t^(t - x), {t, 1, x}, WorkingPrecision -> Precision@x]
f[{x, 2, 2.}]
(* {f[x], f[2], 0.874227} *)
f[x] // NumericQ
(* False *)
f[2] // NumericQ
(* True *)
f[2.] // NumericQ
(* True *)
f[2] + 1.
(* 1.87423 *)
N[f[2], 16]
(* 0.8742270873919437 *)