Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a function $f : \mathbb{R} \rightarrow \mathbb{R}^3$ defined in a rather nasty way in mathematica however it's a smooth function and what not. I am interested in $f'[t]$ and when I run it through ParametricPlot3D, it shows me what I expect it to look like.

When I try run $f'[t]$ or $f[t]$ through NIntegrate however, I always get a NIntegrate::inumr error saying the integrand has evaluated to non-numerical values.

What could be the cause of this, why is it that something I can ParametricPlot3D and also manually set up a numerical integration function for isn't working for NIntegrate?

Thanks in advance.

Additional information:

FF[t_] = Sqrt[d2 E^(- 0.2 t) +  d1 E^(0.2 t) - (b5 / (2 * 0.01))]
GG[s_] := -NIntegrate[Sqrt[d2 E^(- 0.2 t) +  d1 E^(0.2 t) - (b5 / (2 * 0.01))], {t, 0, s}]

Asym[t_?NumericQ] :=  FF[t] * {1, 0, 0} - (Sqrt[0.01 b5 + c5])/(FF[t]^2 )
{0, Cos[GG[t] + Arg[beta5] + Pi], Sin[GG[t] + Arg[beta5] + Pi]}

Everything else is just a real number (beta5 a complex number but Arg[beta5] is a number)

Both of these work fine (I see a nice smooth curve each time):

ParametricPlot3D[Asym[t], {t, 0, 1}]
ParametricPlot3D[Asym'[t], {t, 0, 1}]

Neither of these work:

NIntegrate[Norm[Asym'[t]], {t, 0, 1}]
NIntegrate[Norm[Asym[t]], {t, 0, 1}]

If I calculate the following, it shows me a value for the first entry but not the second two entries implying it is the GG[t] stuffing things up seeing as GG[t] is not used in the first entry of Asym[t] at all.

NIntegrate[Asym[t], {t, 0, 1}]
share|improve this question
I guarantee you that I cannot answer this question, without more information - although, I might be able to guess that you need to restrict your function to be defined for only numerical values using something like t_?NumericQ. – Mark McClure Feb 27 '13 at 21:34
Thanks, I have included additional details as requested. – muzzlator Feb 27 '13 at 21:51
@Szabolcs: Yes but I have now realised now it doesn't work for $f[t]$ either so I suppose the error is somewhere else. – muzzlator Feb 27 '13 at 21:52
I'm very sorry everyone but I have just found if I change the variable t to some other name in the integration, the integration works. I don't understand why but it's now working. Why is it using the same symbol t across different functions? I guess I don't yet fully understand what := does, I just use it when I don't want the function to evaluate. I apologise for wasting everyone's time on what turned out to be a basic mathematica misunderstanding. – muzzlator Feb 27 '13 at 21:58
Scoping issue wherein a t in NIntegrate gets captured. Can repair either by also having GG[s_?NumericQ] := ... or else by defining it with its own t, via GG[s_] := Module[{t}, -NIntegrate[ Sqrt[d2 E^(-0.2 t) + d1 E^(0.2 t) - (b5/(2*0.01))], {t, 0, s}]]. I will add that such questions are more easily answered if all code is provided, in this case that would include assignments for d2, b5, etc. – Daniel Lichtblau Feb 27 '13 at 22:43
up vote 3 down vote accepted

I think what you have is a scoping issue. The t dummy variable in the NIntegrate may be getting captured by symbolic preprocessing of NIntegrate. I'm not certain because I do not see quite the behavior you do. Specifically, this seems to work fine.

NIntegrate[Norm[Asym[t]], {t, 0, 1}]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.