[Paper Review] Computations of general Heun functions from their integral series representations
This paper presents a numerically stable and efficient method for computing general Heun functions using unconditionally convergent integral series representations based on Volterra composition and matrix resolvents. By discretizing the integral equations via a trapezoidal quadrature rule and solving them through matrix inversion of lower-triangular systems, the approach achieves high performance—up to 200× faster than Mathematica’s HeunG and Octave’s HeunL0—especially for large-scale evaluations with moderate accuracy requirements, while maintaining convergence across the complex plane except at singularities.
We present a numerical implementation of the recently developed unconditionally convergent representation of general Heun functions as integral series. We produce two codes in Python available for download, one of which is especially aimed at reproducing the output of Mathematica's HeunG function. We show that the present code compares favorably with Mathematica's HeunG and with an Octave/Matlab code of Motygin, in particular when the Heun function is to be evaluated at a large number of points if less accuracy is sufficient. We suggest further improvements concerning the accuracy and discuss the issue of singularities.
Motivation & Objective
- To develop a numerically stable and efficient algorithm for computing general Heun functions across the complex plane.
- To implement the recently derived unconditionally convergent integral series representation of Heun functions in a practical, open-source numerical framework.
- To enable high-performance evaluation of Heun functions at large numbers of points, particularly when high precision is not required.
- To address the challenge of numerical instability near singularities and provide a robust framework for path integration in the complex plane.
Proposed method
- The method reformulates the Heun differential equation as a matrix ordinary differential equation dU/dz = M(z)U with initial condition U(z₀,z₀) = I, where M(z) is a 2×2 matrix depending on the Heun parameters.
- The solution U(z,z₀) is expressed as an ordered exponential, which is then represented exactly via path-sum formalism using Volterra composition and Neumann series of ∗-resolvents.
- The Volterra composition is discretized using a trapezoidal rule for integration, transforming the infinite integral series into a finite matrix inversion problem involving lower-triangular matrices.
- The ∗-resolvent is approximated as (Id − Δz F + (Δz/2) dF)^{-1} / Δz, where F is a matrix of kernel evaluations and dF is its diagonal, enabling stable and accurate numerical computation.
- The approach is implemented in Python with two codes: one matching Mathematica’s HeunG output and another optimized for speed at moderate accuracy.
- The method avoids direct evaluation of iterated integrals by reducing the problem to matrix multiplication and inversion, leveraging the well-conditioned structure of lower-triangular matrices.
Experimental results
Research questions
- RQ1Can the unconditionally convergent integral series representation of general Heun functions be efficiently implemented in practice despite its apparent computational complexity?
- RQ2How does the performance of the new method compare to established software like Mathematica’s HeunG and Octave’s HeunL0 in terms of speed and accuracy?
- RQ3To what extent can the method be scaled to compute Heun functions at very large numbers of points with acceptable accuracy?
- RQ4How does the method handle numerical challenges near singularities or in the complex plane?
Key findings
- The proposed Python code computes general Heun functions up to 200 times faster than Mathematica’s HeunG and Octave’s HeunL0 when evaluating at 100,000 points with 10⁻⁶ accuracy, achieving a runtime of 0.90 seconds compared to 231 seconds for HeunG.
- For 500,000 points, the code completes in 434 seconds with 10⁻⁶ accuracy, while HeunL0 required over 7 hours for 50,000 points, indicating a significant performance advantage at scale.
- The method achieves machine precision (10⁻¹⁶) for 1,000 points in 2.22 seconds with HeunG-compatible code, and 10⁻¹³ accuracy in 6.05 seconds with HeunL0-compatible code.
- The method remains stable and accurate even when traversing paths in the complex plane near singularities at z=1 and z=t=1+i×10⁻², where other solvers fail or become prohibitively slow.
- The code is robust to singularities when integrating along non-straight contours avoiding them, and the underlying mathematical framework supports analytic continuation via path integration.
- The implementation is open-source and available on GitHub, with two versions: one matching Mathematica’s HeunG output and another optimized for speed at moderate accuracy.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.