# Table not working with Plot

Because NIntegrate[] does not support parallel computation out of the box, I'm doing a simplified version by breaking the integration limit into pieces and using ParallelTable[]. The following code is just a minimum working example in which I used Sinc[] as the integrated function.

iser[x_] := NIntegrate[Sinc[t + x], {t, 0, 100}];

ipar[x_] := Total[ParallelTable[
With[{xx = x}, NIntegrate[Sinc[t + xx], {t, ii*25, ii*25 + 25}]
], {ii, 0, 3}]
];


where iser[] is the usual serialize version, and ipar[] is the parallel version. Then I do DistributeDefinitions[ipar]. Passing a value to iser[] and ipar[] and both give the correct answer:

In:= ipar

Out= -0.270322


But, when I try to run Plot[ipar[x], {x, 0, 10}] // Timing I get error messages that says

 NIntegrate::inumr: The integrand Sinc[t+x] has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,25}}.

NIntegrate::inumr: The integrand Sinc[t+x] has evaluated to non-numerical values for all sampling points in the region with boundaries {{50,75}}.

NIntegrate::inumr: The integrand Sinc[t+x] has evaluated to non-numerical values for all sampling points in the region with boundaries {{75,100}}.

NIntegrate::inumr: The integrand Sinc[t+x] has evaluated to non-numerical values for all sampling points in the region with boundaries {{25,50}}.

NIntegrate::nlim: t = 25. ii is not a valid limit of integration.

General::stop: Further output of NIntegrate::nlim will be suppressed during this calculation.

\$Aborted


I know I can just generate a table of values and use ListPlot[] instead, but it's not easy to do adaptive sampling as Plot[] does. How can this be fixed?

• ipar[x_?NumberQ] := ... – wxffles Nov 9 '12 at 2:23
• @wxffles Thanks. That solves it. Bit strange that ipar returns the correct value without the query ?NumberQ – egwene sedai Nov 9 '12 at 2:56
• Please read this for a full explanation: support.wolfram.com/kb/3820 – Searke Nov 9 '12 at 5:14
• @davidsedai please rename your post to Table not working with Plot as the problem has nothing to do with Parallel in practice. And change the tag? – chris Nov 9 '12 at 7:13
• @Searke Thanks for the link – egwene sedai Nov 9 '12 at 7:22

## 1 Answer

As mentioned in the comments, using a condition for the arguments of ipar and iser is needed.

A broader discussion of how and when to implement this solution is found in this answer.