# Efficient evaluation of complicated numerical functions

I am facing a problem with numerical evaluation of a rather nasty function, given by an infinite (Fourier) sum where coefficients (dependent on one variable of function) are themselves given by definite integrals (sometimes desired upper integration limit is the value of variable). Single coefficient of that sum looks like

(r^(-1 - 2 k) (r^(2 + 4 k)
NIntegrate[\[Rho] (1 + \[Rho]^2)^(1/2 (-3 + Sqrt))
Hypergeometric2F1[1/2 (1 + Sqrt), 1/2 (3 + Sqrt + 4 k),
2 (1 + k), -\[Rho]^2], {\[Rho], 0, 1}] -
r^(2 + 4 k)
NIntegrate[\[Rho] (1 + \[Rho]^2)^(1/2 (-3 + Sqrt))
Hypergeometric2F1[1/2 (1 + Sqrt), 1/2 (3 + Sqrt + 4 k),
2 (1 + k), -\[Rho]^2], {\[Rho], 0, r}] +
r^(2 + 4 k)
NIntegrate[\[Rho]^(3 + 4 k) (1 + \[Rho]^2)^(1/2 (-3 + Sqrt))
Hypergeometric2F1[1/2 (1 + Sqrt), 1/2 (3 + Sqrt + 4 k),
2 (1 + k), -\[Rho]^2], {\[Rho], 0, 1}] +
NIntegrate[\[Rho]^(3 + 4 k) (1 + \[Rho]^2)^(1/2 (-3 + Sqrt))
Hypergeometric2F1[1/2 (1 + Sqrt), 1/2 (3 + Sqrt + 4 k),
2 (1 + k), -\[Rho]^2], {\[Rho], 0, r}]) Sin[(2 k +
1) \[Phi]])/((1 + 2 k) \[Pi] NIntegrate[\[Rho]^(
3 + 4 k) (1 + \[Rho]^2)^(1/2 (-3 + Sqrt))
Hypergeometric2F1[1/2 (1 + Sqrt), 1/2 (3 + Sqrt + 4 k),
2 (1 + k), -\[Rho]^2], {\[Rho], 0, 1}])


This is to be summed over $k=0, 1, ... \infty$ The region in which the function is defined is $\phi\in(-\pi, \pi),~\rho\in(0,1)$. My problem is that I am interested about the behaviour of that function near $\rho=1$, and there the convergence is rather slow, meaning that to get reasonable error for $\rho=0.95$ I need to sum up 100 terms. Then evaluation at single point takes approximately 20 sec., and things like plotting are very painful. So far following suggestions from manual I tried adding Method -> {Automatic, "SymbolicProcessing" -> 0} as option to NIntegrate, but it didn't help a lot. Does anyone have an idea how to speed up the evaluation? References on general rules of numerical evaluation in MMA would also be appreciated! Thanks a lot!

• Is this series amenable to Euler or Kummer transformation? – Chris Nadovich Jul 14 '17 at 14:15
• @ChrisNadovich That's an interesting remark but I'm not sure how check that since I obtain my series by solving a differential equation (from separation of variables). Nevertheless, I'm definitely going to follow that idea – Picek Jul 18 '17 at 12:35