JuliaMath / QuadGK.jl

adaptive 1d numerical Gauss–Kronrod integration in Julia
MIT License
268 stars 37 forks source link

contour integration #67

Closed stevengj closed 1 year ago

stevengj commented 1 year ago

I thought this was supported, but then this integral should give 2πi by the residue theorem:

julia> quadgk(z -> cos(z)/z, 1, im, -1, -im)
(0.50046301807924 + 4.71238898038469im, 4.027482497221434e-9)

and the result looks clearly wrong. 😢

stevengj commented 1 year ago

Oh, nevermind, I forgot to close the contour by ending up back at z=1:

julia> quadgk(z -> cos(z)/z, 1, im, -1, -im, 1)
(0.0 + 6.283185307179587im, 5.369976662961913e-9)