Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I need to do numerical integration --> differentiation --> numerical integration.

I tried to apply the technique described in the accepted answer to a similar question:

y = t^2 x^2;
f[t_?NumericQ] := NIntegrate[y, {x, 1, 2}]
g[t_?NumericQ] := D[f[t], t]
NIntegrate[g[t]*t, {t, 1, 2}]

However, it still generates the error:

NIntegrate::inumr: The integrand g[t] has evaluated to non-numerical values for all sampling points in the region with boundaries {{1,2}}. >>

This approach won't work due to the differentiation in between.

What am I missing?

share|improve this question

closed as off-topic by ciao, ubpdqn, Yves Klett, m_goldberg, belisarius Apr 8 '14 at 11:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – ciao, ubpdqn, Yves Klett, m_goldberg, belisarius
If this question can be reworded to fit the rules in the help center, please edit the question.

The error says it all - you can't use NIntegrate without assigning a value to all variables/constants. See if you can find which var is unassigned –  Sektor Apr 8 '14 at 6:55

1 Answer 1

up vote 0 down vote accepted

To obtain the derivative of the integral, just put the derivative of the integrand inside:

y[t_, x_] = t^2 x^2;
ydt[t_, x_] = D[y[t, x], t];
g[t_?NumericQ] := NIntegrate[ydt[t, x], {x, 1, 2}]
NIntegrate[g[t]*t, {t, 1, 2}]
share|improve this answer
Works perfectly - thank you! –  Brett Apr 8 '14 at 9:47

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