##User-defined functions, numerical approximation, and NumericQ##
User-defined functions, numerical approximation, and NumericQ
Frequently there are questions, to which the answer is to use x_?NumericQ
, about defining functions that call or sometimes are passed to
FindRoot
, NIntegrate
, NMaximize
, NMinimize
, FindMaximum
, FindMinimum
, NDSolve
, ParametricNDSolve
, FindFit
, LinearModelFit
, NonlinearModelFit
, and so on.
Sometimes the analogous VectorQ
, MatrixQ
, or ArrayQ
is the answer (see this answer).
The Wolfram Knowledge Base Article, "Using ?NumericQ to Affect Order of Evaluation" (Wolfram version (dead link); WayBack Machine version), gave a good explanation of how to use NumericQ
; it has been replaced by "How do I use ?NumericQ to affect order of evaluation?"
Edit: This was anticipated over a year ago on Meta.
###Answers in which NumericQ
figured###
Answers in which NumericQ
figured
Here are links to some of the answers in which NumericQ
was a key to the solution of the problem.
The headings include the command(s) and sometimes some error messages characteristic of this problem.
Some answers deal with multiple commands and they are not sorted into combinations, except NIntegrate
/FindRoot
which is a particularly common problem; connections with other functions indicated next to the links.
NIntegrate
/FindRoot
--
1),
2),
3) vector-valued functions.
FindRoot
- FindRoot::nlnum
--
1) (NArgMax
),
2) SingularValueList
, 3).
NIntegrate
- NIntegrate::inumr
, NIntegrate::nlim
--
1),
2),
3) Compile
,
4),
5) NDSolve
,
6) nested NIntegrate
.
NDSolve
--
1a),
1b),
2),
3).
NMinimize
/NMaximize
/FindMinimum
/FindMaximum
- NMinimize::nnum
, FindMinimum::nrnum
--
1) NMinimize
/NMaximize
,
2) FindMinimum
,
3) explanation of the downside of NumericQ
.
FindFit
/LinearModelFit
/NonlinearModelFit
1), 2)
Plotting -- In earlier versions of Mathematica, various plotting functions first evaluated the function to be plotted symbolically, which would result in warnings. As of V9 or perhaps earlier, these warnings were no longer emitted. [As of V10.2, ParametricPlot
seems to be an exception.] 1) [As of, at least v11.0, RegionPlot3D
is also an exception.] 2)