How to evaluate a complex function between complex bounds

I’m having trouble evaluating the following expression that contains an integral with a complex function with complex bounds.

In this expression, \phi() is the PDF of a standard normal distribution, \beta is a number >0, and \kappa is a vector of both negative and positive numbers of length n - 1. In a particular example that I’m studying, the following values are used for \beta and \kappa:

β = 2.4660212074327954
κ = [-0.15473970173530405, -0.03989979101500318, -8.945133695399355e-11]

I have tried to evaluate the integral using QuadGK package, using the following code:

Integral, _ = quadgk(s -> (1 / s) * exp((s + β)^2 / 2) * prod(1./sqrt.((1 .+ s .* κ))), 0 + 0 * im, 0 + Inf * im)
PoF = pdf(Normal(0, 1), β) * real(im * sqrt(2 / π) * Integral)

But I get DomainError with 0.0 + Inf*im.

I know that for the particular values of \beta and \kappa above, the whole expression should evaluate to 0.00936. I would appreciate if somebody could help me with this integral.

You can do a substitution s = ix to make your integration variable real. But the real part of your integral (i.e., the imaginary part of the expression inside the Re) diverges, so you have to pull the real inside the integral to get something finite. Still, I can’t reproduce the value you’re claiming for the expression. Here’s what I get:

using Distributions
using QuadGK

β = 2.4660212074327954
κ = [-0.15473970173530405, -0.03989979101500318, -8.945133695399355e-11]

f(s, β, κ) = inv(s) * exp((s + β)^2 / 2) * prod(k -> inv(sqrt(1 + s * k)), κ)
integral, error = quadgk(x -> -real(f(im * x, β, κ)), 0, Inf)
pof = pdf(Normal(0, 1), β) * sqrt(2 / π) * integral
@show pof
@show error
# pof = -0.4946133368632261
# error = 5.552972283529805e-9
3 Likes

Thanks, @danielwe, at least now I start getting an actual value instead of an error. Still trying to figure out why the expression does not evaluate to the 0.00936.

1 Like