# Domain error at the integrand using QuadGK

**URL:** <https://discourse.julialang.org/t/domain-error-at-the-integrand-using-quadgk/60076>\
**Category:** General Usage\
**Tags:** integral\
**Created:** [April 27, 2021, 2:38am UTC](https://discourse.julialang.org/t/domain-error-at-the-integrand-using-quadgk/60076 "2021-04-27T02:38:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![leopdsf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/leopdsf/32/31008_2.png) [@leopdsf](https://discourse.julialang.org/u/leopdsf)\
**Post date:** [April 27, 2021, 2:38am UTC](https://discourse.julialang.org/t/domain-error-at-the-integrand-using-quadgk/60076/1 "2021-04-27T02:38:55Z")

</div>

Hello, everyone! I am trying to perform the numerical integration of the function \tanh^2(z) using QuadGK.jl with the following code

```julia
using Plots
using QuadGK

k(z) = tanh(z)^2
plot(k)
Q = quadgk(k,-Inf,Inf)

```

but when I try to run, I receive the following error message

```julia
DomainError with -0.9999999999999964:
integrand produced Inf in the interval (-1.0, -0.9999999999999929)

```

I’m not understanding why, since \tanh^2z does not diverge for any z. Does anyone know whats happening?

---

<div class="post-metadata">

**Author:** ![Bruno\_Amorim](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@Bruno\_Amorim](https://discourse.julialang.org/u/Bruno_Amorim)\
**Post date:** [April 27, 2021, 3:20pm UTC](https://discourse.julialang.org/t/domain-error-at-the-integrand-using-quadgk/60076/2 "2021-04-27T15:20:26Z")

</div>

`tanh(x)` tends to \pm 1 as x\rightarrow \pm \infty. So the integral you want to evaluate diverges.
