It appears that, counter to my expectation, all of these (and probably many others) seem to work fine:
Plot[Hold[x], {x, 0, 10}]
FindRoot[Hold[x^2 == 2], {x, 1}]
NMinimize[Hold[x^2], x]
I would expect Plot or NMinimize to complain that e.g. Hold[0] is not a number.
These were mentioned a few times on this site but didn't get any attention: (1) (2).
Doing this does appear to solve problems which would normally require _?NumericQ.
Is this usage of Hold supported? Is it meant to work this way, does it work by design, or is it accidental?
My guess is that these work accidentally because these functions use ReleaseHold internally.
NMinimize[Hold[Print["hi"]; x^2], x]causes my kernel to crash.NMinimize[Hold[x]^2, x]complains andNMinimize[Hold@Hold[x^2], x]works; however,NMinimize[Hold@Hold@Hold[x^2], x]does not. I suppose it could beReleaseHold, but not in the ordinary way. – Michael E2 Mar 04 '14 at 00:09ReleaseHolds than necessary and whether that is intended or a lack of attention. In any case it seem to not cause much problems, I think? – Albert Retey Mar 04 '14 at 10:41Experimental\NumericalFunction, which is definitely used byNMinimize` and probably by the others. But I don't really know anything about this undocumented function and so can't elaborate further. – Oleksandr R. Mar 04 '14 at 23:50