# Complex Numerical Integration using GSL

I want to program an integration routine in C++ using the GSL library but for complex functions.

How should I split my integrand to apply the gsl_integration_qag function on it.

Just integrate the real and imaginary parts by themselves is not correct I guess.

I have the following function: $$S(a,N) = S(a, \infty) - \sum^{\infty}_{n = 1} \frac{1}{n + N}$$ where $S(a, \infty)$ is some real constant. The functions I later intend to integrate are using the harmonic sum as a basis but are just sums of it.

The integration I intend to do is the Mellin transform which is given by: $$f(x) = \frac{1}{2 \pi i} \int_C dn x^{-n} f^{M}(n).$$

Any help is much approciated.

EDIT: Any idea on a C++ program for complex numerical integration?

• Complex integration is a more subtle business than real integration; it depends on what you precisely mean: contour integrals? path integrals? are the integrands holomorphic or do they contain poles? It would be helpful if you could add an example of the type of integral you're trying to compute. – Christian Clason Apr 24 '16 at 10:40
• Thanks for your answer @ChristianClason ! I mean contour integration and the integrands contain poles. I actually want to compute the inverse mellin transform of functions containing harmonic sums. I don't have an example at hand right now but I'll provide one. I wrote a program using simspons rule but it delivers wrong results for harmonic sums, although it does deliver the right results for simple functions like 1/z for e.g. – Silverwhale Apr 24 '16 at 10:48
• You should edit your answer to include this information (comments can go away, or be buried in a long thread, and are very small :)) – Christian Clason Apr 24 '16 at 11:03
• Any reason you're not using a specific method for the inverse Mellin transform, e.g., sciencedirect.com/science/article/pii/037704279190041H or link.springer.com/article/10.1007%2FBF01932274#page-1? – Christian Clason Apr 24 '16 at 11:04
• I have the following function: $$S(a,N) = S(a, \infty) - \sum^{\infty}_{n = 1} \frac{1}{n + N}$$ where $S(a, \infty)$ is some real constant. The functions I later intend to integrate are using the harmonic sum as a basis but are just sums of it. and the Mellin transform is given by: $$f(x) = \frac{1}{2 \pi i} \int_C dn x^{-n} f^{M}(n).$$ – Silverwhale Apr 24 '16 at 11:06