Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hcubature hangs on some integrand #25

Closed
mzaffalon opened this issue Jan 19, 2017 · 4 comments
Closed

hcubature hangs on some integrand #25

mzaffalon opened this issue Jan 19, 2017 · 4 comments

Comments

@mzaffalon
Copy link

hcubature seems to hang for some integrands when the integrand is symmetric in the domain of integration and the tolerance is sufficiently high.

julia> hcubature(x -> (1.0+(x[1]*x[3]*cos(x[2]))^2), [0,0,-0.2], [0.2,2π,0.2], abstol=1e-6)
(0.5026995050032178,3.3306690738754696e-16)
julia> hcubature(x -> (1.0+(x[1]*x[3]*sin(x[2]))^2), [0,0,-0.20001], [0.2,2π,0.2], abstol=1e-6) # note the domain of integration
(0.502712074725032,4.440892098500626e-16)
julia> hcubature(x -> (1.0+(x[1]*x[3]*sin(x[2]))^2), [0,0,-0.2], [0.2,2π,0.2], abstol=1e-6) # hangs forever
julia> hcubature(x -> (1.0+(x[1]*x[3]*sin(x[2]))^2), [0,0,-0.2], [0.2,2π,0.2], abstol=1e-3) # note the reduced tolerance
(0.5026887210432646,3.325688687261241e-5)

(Sorry for the contrived example: I could not find one with lower dimensionality.)

@mzaffalon
Copy link
Author

mzaffalon commented Nov 27, 2020

The same integral does not hang with HCubature:

using HCubature
julia> @time hcubature(x -> (1.0+(x[1]*x[3]*sin(x[2]))^2), [0,0,-0.2], [0.2,2π,0.2], atol=1e-6)
  0.051035 seconds (200.74 k allocations: 10.392 MiB)
(0.5026995050032179, 0.0)

EDIT: ... because it was fixed in JuliaMath/HCubature.jl#4 (comment)

@stevengj
Copy link
Member

Yes, same as JuliaMath/HCubature.jl#4 and stevengj/cubature#7. This needs to be fixed in the underlying C library.

@stevengj
Copy link
Member

Should be fixed by JuliaRegistries/General#25426.

@stevengj
Copy link
Member

Yup, it works now:

julia> Cubature.hcubature(x -> (1.0+(x[1]*x[3]*sin(x[2]))^2), [0,0,-0.2], [0.2,2π,0.2], abstol=1e-6)
(0.5026995050032179, 1.1102230246251565e-16)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants