JuliaMath / HCubature.jl

pure-Julia multidimensional h-adaptive integration
Other
148 stars 23 forks source link

Bounds order while using hquadrature #23

Closed rpetit closed 5 months ago

rpetit commented 4 years ago

Hi, I noticed some weird behaviour while using hquadrature: hquadrature(t->1, 0, -1)[1] outputs 1, while, mathematically speaking, it should be -1. Is this intended, or does anybody have an idea of why is this happening ?

Thank you in advance for your help !

stevengj commented 4 years ago

Yes, it seems like the calls to abs on this line and this line may be undesirable. (In the latter case we will have to add abs calls to the Δ[i] > Δ[kdivide] check, however.)

A PR with a test would be welcome.

rpetit commented 4 years ago

Thanks, I'll see if I can find some time to come up with a PR !

aakhmetz commented 4 years ago

*** I spent all night from midnight to 5am trying to figure out the mistake in a complicated but working program

quadgk(x -> (gammacdf(shape, scale, S_R-x) - gammacdf(shape, scale, S_L-x)), E_L, S_L, rtol=ε)[1] gave -2.724235379524588 hquadrature(x -> (gammacdf(shape, scale, S_R-x) - gammacdf(shape, scale, S_L-x)), E_L, S_L, rtol=ε)[1] gave 2.724235379524588

Thank you very much!

aakhmetz commented 4 years ago

It looks like I did update my Julia packages, but Jupyter notebook was not updated. I am sorry for disturbing - it looks working perfectly now