# Numerical integration using hcubature\

Hello everyone,

I’m transitioning from python to Julia and I’m trying to compute some integrals using hcubature

I’m trying to compute the following integral, for which the constant \beta is equal to 1

As seen from the picture, the numerical result to the integral is approximately 25.80

In Julia, I am trying to compute the integral above this way:

using HCubature
β = 1
hcubature(x -> log(cosh(2 * β) ^ 2 - sinh(2 * β) * (cos(x) + cos(x))), (pi, 0), (pi,0))



which gives 0.0 as the answer.

In python, I would compute the same integral using nquad the following way:

import numpy as np
ff = lambda x1, x2: np.log(np.cosh(2 * beta) ** 2 - np.sinh(2 * beta) * (np.cos(x1) + np.cos(x2)))


this gives me the correct result of 25.80.

What am I doing wrong with hcubature?

I think you’ve just got the bound arguments mixed up, its not (xmin, xmax), (ymin, ymax) rather its (xmin, ymin), (xmax, ymax), so should be
julia> hcubature(x -> log(cosh(2 * β) ^ 2 - sinh(2 * β) * (cos(x) + cos(x))), (0,0), (pi,pi))

Thank you for pointing that out!! 