1

If I use symbolic integration for the following:

Sum[Integrate[i + x, {x, 1, 7}], {i, 1, 7}]

336

as one can see it gives the answer as it seems to 'understand' the sum integral.

However with

NSum[NIntegrate[i + x, {x, 1, 7}], {i, 1, 7}]

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

336.

As one can see it does not seem to know that $i$ is 1 I think or something like that.

What is the problem and how can I format the numerical functions to do what I want without these errors?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
onepound
  • 343
  • 1
  • 9

1 Answers1

2

Define a function that can only be called with a numerical argument $i$:

f[i_?NumericQ] := NIntegrate[i + x, {x, 1, 7}]

Numerical sum without possibility of analytic attempts at integration:

NSum[f[i], {i, 1, 7}]
(*    336.    *)
Roman
  • 47,322
  • 2
  • 55
  • 121