# \`Inf\` does not work in \`quadgk!()\`

**URL:** <https://discourse.julialang.org/t/inf-does-not-work-in-quadgk/72838>\
**Category:** Numerics\
**Tags:** package, integral\
**Created:** [December 9, 2021, 4:43pm UTC](https://discourse.julialang.org/t/inf-does-not-work-in-quadgk/72838 "2021-12-09T16:43:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HJWang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hjwang/32/28697_2.png) [@HJWang](https://discourse.julialang.org/u/HJWang)\
**Post date:** [December 9, 2021, 4:43pm UTC](https://discourse.julialang.org/t/inf-does-not-work-in-quadgk/72838/1 "2021-12-09T16:43:07Z")

</div>

I tried to use `quadgk!()`, which is the in-place `quadgk()`, but encountered problems. Simply put, `quadgk!()` does not accpet `Inf` or `-Inf` in the domain boundary while it is not a problem with `quadgk()`. The following is a MWE.

```julia
julia> using QuadGK, StatsFuns

julia> f(x) = normpdf(x)
f (generic function with 1 method)

julia> f!(y,x) = y .= f(x)
f! (generic function with 1 method)

julia> int_g = zeros(1)
1-element Vector{Float64}:
 0.0

julia> # without `Inf` both are fine

julia> quadgk(f, 0.0, 1.0)
(0.341344746068543, 9.992007221626409e-16)

julia> quadgk!(f!, int_g, 0.0, 1.0)
([0.341344746068543], 9.992007221626409e-16)

julia> # with `Inf` problem arises

julia> quadgk(f, 0.0, Inf) # fine
(0.4999999999999999, 5.67681333382849e-9)

julia> quadgk!(f!, int_g, 0.0, Inf) # not work
ERROR: MethodError: objects of type QuadGK.InplaceIntegrand{typeof(f!), Vector{Float64}, Vector{Float64}} are not callable

```

Is it a bug or a design feature? If it is the former, could it be fixed? Thanks.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [December 9, 2021, 5:18pm UTC](https://discourse.julialang.org/t/inf-does-not-work-in-quadgk/72838/2 "2021-12-09T17:18:08Z")

</div>

It’s a bug; we didn’t handle the infinite-domain case when implementing the in-place API.

It’s fixable, but in the meantime you can just do the coordinate transformation to a finite domain manually.

---

<div class="post-metadata">

**Author:** ![HJWang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hjwang/32/28697_2.png) [@HJWang](https://discourse.julialang.org/u/HJWang)\
**Post date:** [December 9, 2021, 6:09pm UTC](https://discourse.julialang.org/t/inf-does-not-work-in-quadgk/72838/3 "2021-12-09T18:09:50Z")

</div>

Got it. Thanks!
