# Error when doing integration with QuadGK

**URL:** <https://discourse.julialang.org/t/error-when-doing-integration-with-quadgk/94487>\
**Category:** General Usage\
**Created:** [February 12, 2023, 4:39am UTC](https://discourse.julialang.org/t/error-when-doing-integration-with-quadgk/94487 "2023-02-12T04:39:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Firstname\_Lastname](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/firstname_lastname/32/34201_2.png) [@Firstname\_Lastname](https://discourse.julialang.org/u/Firstname_Lastname)\
**Post date:** [February 12, 2023, 4:39am UTC](https://discourse.julialang.org/t/error-when-doing-integration-with-quadgk/94487/1 "2023-02-12T04:39:11Z")

</div>

I used the following code

```julia
using QuadGK
v = quadgk(x->cos(x)^2/((x+1)*(x^2-x+1)),-pi,0)[1]

```

and got the error below

ERROR: DomainError with -1.0000000000000009:  
integrand produced Inf in the interval (-1.0000000000000022, -0.9999999999999996)

Please help me to resolve this situation.

Thank you.

---

<div class="post-metadata">

**Author:** ![Firstname\_Lastname](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/firstname_lastname/32/34201_2.png) [@Firstname\_Lastname](https://discourse.julialang.org/u/Firstname_Lastname)\
**Post date:** [February 12, 2023, 4:41am UTC](https://discourse.julialang.org/t/error-when-doing-integration-with-quadgk/94487/2 "2023-02-12T04:41:52Z")

</div>

Ooops, I see. It is clear from the error message. Sorry for posting the above question.
