# How to figure out why I'm getting a NIntegrate::inumr (nonnumeric values) error?

When I execute the following I get an error:

NIntegrate[a x, {x, 0, 1}]


NIntegrate::inumr: The integrand a x has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,1}}.

(*  NIntegrate[a x, {x, 0, 1}]  *)


How can I figure out why?

• I wrote this so that it might be linked as duplicate in appropriate cases. I was going to make the Q&A CW, but I couldn't find the CW button for the question. – Michael E2 Jul 21 '17 at 5:01
• I've done it. If you want anything of yours wiki'd and you can't do it, just flag. – J. M.'s discontentment Jul 30 '17 at 18:08
• @J.M. Thanks. I'm still wondering whether this Q&A is going to be useful.... – Michael E2 Jul 31 '17 at 15:43

The easiest way is to test your integrand f and see if it evaluates to a numeric value. Plug in a numerical value like this:

a x /. x -> 0.5
(* 0.5 a *)


As you can see it evaluated to 0.5 a, which contains a Symbol and is not a number. In this case, the problem was an undefined parameter. Another common issue is an improper function call:

f[x_, y_] := x Cos[y];
NIntegrate[f[ReIm[Exp[2 Pi I t]]], {t, 0, 1}]


NIntegrate::inumr: The integrand f[{Re[E^(2 I π t)],Im[E^(2 I π t)]}] has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,1}}.

(*  NIntegrate[f[ReIm[Exp[2 π I t]]], {t, 0, 1}]  *)


Test the integrand:

f[ReIm[Exp[2 Pi I t]]] /. t -> 0.5
(*  f[{-1., 1.22465*10^-16}]  *)


The function f is called on a List, not on the individual coordinates, which does not match its definition. As a result, it does not evaluate to a numeric value. (The fix is either to integrate f @@ ReIm[Exp[2 Pi I t]] or to change the definition to f[{x_, y_}] :=..., but the fix will depend on each particular case.)

Note I plugged in a machine float 0.5 to test the function, not an exact number such as 1/2. A machine input should evaluate to a machine number if everything is working. An exact input will evaluate to an exact expression, which may be as complicated as your integrand: it may be hard to tell if the result is numeric, and if not, you may not see the undefined parameters, such as a in the OP.

It's possible to pick a bad number to plug in that results in a numeric error, such as division by zero. Usually you can try a different number. When it seems hopeless, you can replace NIntegate by Table to test many values. This is easily done by copying the input. You should change the iteration to give several floating-point numbers:

Table[a x, {x, 0., 1., 0.1}]


You can also try plotting, but you do not see which parameters, function calls or whatever is causing the trouble:

Plot[a x, {x, 0, 1}]