I am experimenting with Parallelize
and ParallelTable
This is the code I am using:
K[a_, b_, r_] = a*Exp[-r/b]/r;
T = D[K[10^5, 10^9, s], s]/299792^2 /. s -> 7.6
R = Range[0, 7, 0.01];
\[Theta] = Range[0, 2*Pi, 0.05];
RcG[d_, t_] = Sqrt[7.6^2 + d^2 - 2*7.6*d*Cos[t]];
f[a_?NumberQ, b_?NumberQ] :=
1/299792^2*NIntegrate[K[10^5, 10^9, x], {x, 7.6 - a, b}];
tab = Parallelize[
Table[1/299792^2*
d*(K[10^5, 10^9, RcG[d, t]] - K[10^5, 10^9, 7.6] - d*T) +
f[d, RcG[d, t]], {d, R}, {t, \[Theta]}]];
p1 = ListPlot3D[tab, InterpolationOrder -> 4]
I want make a 3d plot using the complicated function defined in the table. When computing, Mathem. gives this error a lot of times:
NIntegrate::inumr: The integrand K[100000,1000000000,x] has evaluated to non-numerical values for all sampling points in the region with boundaries {{7.3,7.30039}}.
It doesn't happen without the Parallelize
, so this means that I am using it wrongly, but I don't get where. I also used ParallelTable
, with the same result.