Reputation: 119
I am calculating the integral above.
My code is
using HCubature
function FUN_trans(x)
return k1_FUN([1/x[1]-1, 1/x[2]-1, x[3], x[4], 1/x[5]-1]) / x[1] / x[1] / x[2] / x[2] / x[5] / x[5]
end
function k1_FUN(x)
k1 = x[1]
k2 = x[2]
x1 = x[3]
x2 = x[4]
p = x[5]
psq = p*p
k1sq = k1*k1
k2sq = k2*k2
num1 = 2*k1sq - 2*k1*p*x1 + psq + 2
num2 = 2*k2sq - 2*k2*p*x2 + psq + 2
num3 = p*p/2
y = k1sq / (k1sq + 1) * k2sq / (k2sq + 1) / 4
y = y * num1 /(k1sq -2*x1*k1*p + psq +1)
y = y * num2 /(k2sq -2*x2*k2*p + psq +1)
y = y /(num1*num1 - num3*num3)
y = y /(num2*num2 - num3*num3)
return y
end
lower1 = [0, -1, -1, 0, 0]
upper1 = [1, 1, 1, 1, 1]
result, error = hcubature(FUN_trans1, lower1, upper1)
println(result)
println(error)
I am using a transformation
x -> 1/x - 1
on all variables integrated on [0, +Inf].
The program returns a result of nan. But this integral is testified to be converged. What should I do to get the correct result of this integral?
Upvotes: 0
Views: 32