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

hquadrature hangs for function that integrates to zero (unless abstol is set) #34

Open
ngiann opened this issue Dec 8, 2017 · 2 comments

Comments

@ngiann
Copy link

ngiann commented Dec 8, 2017

hquadrature(sin, 0.0, 2*pi)

Info on my machine and Julia version:

Julia Version 0.6.1
Commit 0d7248e2ff (2017-10-24 22:15 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-4800MQ CPU @ 2.70GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.9.1 (ORCJIT, haswell)

@SalmonLA
Copy link

For future reference, it helps to specify an absolute tolerance to ensure convergence:
hquadrature(sin, 0.0, 2*pi,abstol = 1e-8)
(Found on https://stackoverflow.com/questions/29292614/how-to-do-two-variable-numeric-integration-in-julia#comment46814673_29302840)

@stevengj stevengj changed the title hquadrature hangs on simple example hquadrature hangs for function that integrates to zero Nov 15, 2023
@stevengj
Copy link
Member

As explained in the manual:

More precisely, the integration will terminate when either the relative- or the absolute-error tolerances are met. abstol defaults to 0, which means that it is ignored, but it can be useful to specify an absoute error tolerance for integrands that may integrate to zero (or nearly zero) because of large cancellations, in which case the problem is ill-conditioned and a small relative error tolerance may be unachievable.

The question is whether there is a way for us to reliably detect that you have specified an unachievable relative tolerance here, in order to terminate automatically.

(One idea that has been suggested is to estimate the integral of |f(x)| or similar, in order to be able to set a default absolute tolerance relative to this.)

@stevengj stevengj changed the title hquadrature hangs for function that integrates to zero hquadrature hangs for function that integrates to zero (unless abstol is set) Nov 15, 2023
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

3 participants