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

Inconsistent results for Inf integrands #29

Open
agerlach opened this issue Aug 27, 2020 · 3 comments
Open

Inconsistent results for Inf integrands #29

agerlach opened this issue Aug 27, 2020 · 3 comments

Comments

@agerlach
Copy link

I am looking at some SciML problems where, depending on the stability of the ODE, the integrand used w/ HCubature.jl may return Inf. I am noticing inconsistent behavior across hquadrature and hcubature for single and multi-dim domains.

using HCubature

g(x) = x[1] > 0.0 ? Inf : x[1]

hquadrature(g, -1.0, 1.0)    #Inf
hcubature(g, -ones(1), ones(1)) #Inf
hcubature(g, -ones(2), ones(2)) #NaN

I see similar behavior in Cubature.jl as well, but Cubature.hcubature returns Inf up to dim = 4 and then NaN, while Cubature.pcubature returns Inf up dim = 17 (haven't test passed that).

Is this the expected behavior? I assume this is due to some Inf*0 that is propagating down.

Thanks.

@stevengj
Copy link
Member

I'm not sure off the top of my head what might give a NaN, but probably only a small patch is required to return Inf.

@agerlach
Copy link
Author

Sign changes in coefficients g.w leads to I=NaN due to Inf-Inf

I = V * (g.w[1]*f₁ + g.w[2]*f₂ + g.w[3]*f₃ + g.w[4]*f₄ + g.w[5]*f₅)

I am happy to put together a PR to address this corner case, but it is unclear to me what the appropriate behavior should be. My initial thought is to short-circuit the algorithm and return Inf if f ever returns Inf.

@agerlach
Copy link
Author

On second thought short-circuiting would not be a good approach b/c integrand could be vector-valued mixing Inf and finite values.

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