##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](https://mathematica.stackexchange.com/questions/16694/numericq-equivalent-for-lists/19600#19600)).

The Wolfram Knowledge Base Article, "Using ?NumericQ to Affect Order of Evaluation" ([Wolfram version (dead link)](http://support.wolfram.com/kb/3820); [WayBack Machine version](https://web.archive.org/web/20140709133301/http://support.wolfram.com/kb/3820)), gave a good explanation of how to use `NumericQ`; it has been replaced by ["How do I use ?NumericQ to affect order of evaluation?"](http://support.wolfram.com/kb/12502)

*Edit:* [This was anticipated over a year ago on Meta](https://mathematica.meta.stackexchange.com/questions/436/candidate-topics-posts-for-canonical-questions/438#438).


###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)](https://mathematica.stackexchange.com/questions/16422/solving-integrals/16426#16426),
[2)](https://mathematica.stackexchange.com/questions/24704/is-it-possible-to-treat-starting-values-as-variables/24705#24705),
[3)](https://mathematica.stackexchange.com/questions/89797/more-issues-integrate-nintegrate-findroot/89803#89803) vector-valued functions,

 - **`FindRoot` - `FindRoot::nlnum`** --
[1)](https://mathematica.stackexchange.com/questions/10399/wrong-use-of-numberq/10404#10404) (`NArgMax`),
[2)](https://mathematica.stackexchange.com/questions/7551/find-determinant-or-row-reduce-parameter-dependent-matrix/7553#7553) `SingularValueList`, [3)](https://mathematica.stackexchange.com/questions/24399/finding-the-root-of-a-nested-function-with-small-values),

 - **`NIntegrate` - `NIntegrate::inumr`, `NIntegrate::nlim`** --
[1)](https://mathematica.stackexchange.com/questions/15875/plot-holdall-and-the-color-problem/15876#15876),
[2)](https://mathematica.stackexchange.com/questions/9891/plotting-multivariable-integration/9914#9914),
[3)](https://mathematica.stackexchange.com/questions/17993/using-a-compiled-function-inside-nintegrate-gives-compiledfunctioncfsa-messa/17994#17994) `Compile`,
[4)](https://mathematica.stackexchange.com/questions/8899/how-do-i-prevent-nintegrateinumr-errors-within-other-functions/8900#8900),
[5)](https://mathematica.stackexchange.com/questions/3639/nintegrate-is-resetting-my-variables-and-not-giving-me-a-result/3641#3641) `NDSolve`,
[6)](https://mathematica.stackexchange.com/a/135164/4999) nested `NIntegrate`,

 - **`NDSolve`** --
[1a)](https://mathematica.stackexchange.com/questions/6751/optimization-problem-with-ndsolve/6764#6764),
[1b)](https://mathematica.stackexchange.com/questions/6751/optimization-problem-with-ndsolve/6755#6755),
[2)](https://mathematica.stackexchange.com/questions/18932/using-dsolve-to-solve-for-xt-parameter/19053#19053),
[3)](https://mathematica.stackexchange.com/questions/25260/ndsolve-with-vector-function/25287#25287),

 - **`NMinimize`/`NMaximize`/`FindMinimum`/`FindMaximum` - `NMinimize::nnum`, `FindMinimum::nrnum`** --
[1)](https://mathematica.stackexchange.com/questions/333/combined-numerical-minimization-and-maximization/336#336) `NMinimize`/`NMaximize`,
[2)](https://mathematica.stackexchange.com/questions/22210/what-is-the-correct-way-to-use-nintegrate-inside-the-findminimum-function/22216#22216) `FindMinimum`,
[3)](https://mathematica.stackexchange.com/questions/4002/minimizing-a-function-of-many-coordinates/4010#4010) explanation of the downside of `NumericQ`,

 - **`FindFit`/`LinearModelFit`/`NonlinearModelFit`**
[1)](https://mathematica.stackexchange.com/questions/10089/how-to-use-findfit-to-fit-an-implicit-function/10091#10091), [2)][1]

 - **Plotting** -- In earlier versions of *Mathematica*, various plotting functions first evaluate the function to be plotted *symbolically*, which would result in warnings. As of V9 or earlier, these warnings were no longer emitted. [As of V10.2, `ParametricPlot` seems to be an exception.]  [1)](https://mathematica.stackexchange.com/questions/9891/plotting-multivariable-integration/9914#9914) [As of, at least v11.0, `RegionPlot3D` is also an exception.]


  [1]: https://mathematica.stackexchange.com/q/25905/121