2

I am interested in certain hypergeometric functions $ G_p(z) = \frac{1}{2} {}_3F_2 \left( \begin{matrix} p & p + 1 & \frac{1}{2} \\ 1 + i & 1 - i & \end{matrix} ;z \right) $ and would like to plot them in the complex $z$ plane, on both sides of the branch cut $\operatorname{Re} z \in (1,\infty)$. However

G[p_, z_] := 1/2 HypergeometricPFQ[{-p, p + 1, 1/2}, {I + 1, -I + 1}, z]
ComplexPlot[G[1/2, z], {z, -I, 2 + I}, PerformanceGoal -> "Speed", ColorFunction -> "GreenPinkTones"]

takes at least 5 minutes to evaluate. (I ran it inside TimeConstrained.) I thought maybe this is just because there is a lot of detail for ComplexPlot to resolve. (Actually, I'd like the plot with ColorFunction -> "CyclicReImLogAbs", which would be even more computationally intensive in that case. And eventually with PerformanceGoal -> "Quality", too.) I tried evaluating the function on a fixed grid to see if that excessive detail was the problem:

mesh = Flatten@Table[{x + I y}, {x, -1, 1, 0.1}, {y, -1, 1, 0.1}];
AbsoluteTiming@G[1/2, mesh]/Length@mesh
(* 0481893 *)

≈ 50 ms per function evaluation, no wonder plotting it is slow!

In contrast, evaluating and plotting ${}_2F_1$ is reasonably fast:

H = Hypergeometric2F1[-9/14, 1, -2/3, #] & ;
EchoTiming@ComplexPlot[H[z], {z, -I, 2 + I}, PerformanceGoal -> "Speed",
 ColorFunction -> "GreenPinkTones"
 ]
(* 0.876022 *)
EchoTiming@ComplexPlot[H[z], {z, -I, 2 + I}, PerformanceGoal -> "Speed",
 ColorFunction -> "CyclicReImLogAbs"
]
(* 2.98155 *)
First@AbsoluteTiming@H[mesh]/Length@mesh
 (* 0.0000524331 *)

As seen on the last line, ${}_2F_1$ is roughly $1000$ times faster to evaluate than ${}_3F_2$! I saw elsewhere on MMA.SE that MeijerGReduce could offer speedups, but it didn't work in this case.

Is this because higher hypergeometric functions are inherently expensive to compute? Is it a known issue? Is there anything I can do to speed the computations up?

I am on Linux, Mathematica 13.0, i9-10900K @ 3.70 GHz. The machine scores 4.49 on the WolframMark Benchmark.

Robin Ekman
  • 121
  • 2
  • 2
    "Is this because higher hypergeometric functions are inherently expensive to compute?" - pretty much, more so that you have complex denominator parameters involved. – J. M.'s missing motivation Jun 08 '22 at 20:35
  • @J.M. deleting the imaginary parts of the denominator does not speed up the computation significantly, and I've had the same issue with purely real parameters before. I've also heard that evaluating MeijerG with the integral definition is efficient, but maybe this was mistaken. And some things just can't be helped I guess. – Robin Ekman Jun 08 '22 at 20:57
  • Having said that: if the computation being done internally by ComplexPlot[] is anything like what's being done here, then the choice of ColorFunction doesn't actually matter; any choice should still take about the same amount of computational effort. – J. M.'s missing motivation Jun 08 '22 at 22:13
  • @J.M. with ${}_2F1$ I consistently find a factor ≈ 3 difference between a simple argument to color map and the CyclicReimLogAbs map. If you look at the output plots, the latter shows much more detailed features of the function. I put both through RuntimeTools``Profile and the latter shows about 3-4 times as many calls to Hypergeometric2F1 as the former. Maybe I'm not interpreting the output correctly, but I doubt it. – Robin Ekman Jun 09 '22 at 01:39
  • @RobinEkman On my compute it finished in 641 s, it takes 15% CPU, 200 Mb memory, and GPU 3D (what for?) in v13.0.1 for Win. Also nothing to see on this picture since quality is very low. Apparently in v.13.0.1 all graphic packages are very slow. But this one is a champion :) – Alex Trounev Jun 09 '22 at 08:48
  • But probably a champion is ContourPlot[G[1/2, x + I y] // Arg, {x, 0, 2}, {y, -1, 1}, ColorFunction -> Hue] // AbsoluteTiming. It takes 3754.8 s on my computer and nothing to see on this picture. What is the problem here? – Alex Trounev Jun 09 '22 at 09:56
  • @J. M.: Your guess "more so that you have complex denominator parameters involved" does not correspond to reality: N[HypergeometricPFQ[{-p, p + 1, 1/2}, {I + 1, -I + 1}, z] /. {z -> 2 - I, p -> 1/2}] // AbsoluteTiming results in {0.708953,0.725416 +0.37877 I} and N[HypergeometricPFQ[{-p, p + 1, 1/2}, {1, 1}, z] /. {z -> 2 - I, p -> 1/2}] // AbsoluteTiming produces {9.50802, 0.555427 + 0.809427 I} on my comp. " – user64494 Jun 09 '22 at 17:11

0 Answers0