Consider the following code:
DistrToy[thh_, EM_] =
Exp[-((EM*(1 - 0.5 Cos[thh]^4))/125)]*Cos[thh]^20;
TableDataTemp1 =
Table[{thh, Eh, DistrToy[thh, Eh]}, {thh, Subdivide[0, Pi, 314]}, {Eh, 125.,
3000., 5.}];
TableData := Flatten[TableDataTemp1, {2, 1}]
DistrToyInterpolated =
Interpolation[TableData, InterpolationOrder -> 1]
Timing[NIntegrate[DistrToy[thh, Eh], {thh, 0, Pi}, {Eh, 125, 3000}]]
Timing[NIntegrate[
DistrToyInterpolated[thh, Eh], {thh, 0, Pi}, {Eh, 125, 3000}]]
Here I define a function DistrToy[thh,Eh], make a table with rows {{thh,Eh, DistrToy[thh,Eh]}} and then make an interpolation. In the end I compare the time which is needed to integrate the initial function and the interpolation over the domain of the interpolation.
I found that the times of the integrations are different: the interpolated function is integrated 40 times longer than the initial function (0.078 s vs 3.125 s)! This makes all related computations extremely slow.
How to fix this issue?