# Julia integral calculation - community module or own module?

**URL:** <https://discourse.julialang.org/t/julia-integral-calculation-community-module-or-own-module/24278>\
**Category:** General Usage\
**Tags:** gpu, packages\
**Created:** [May 16, 2019, 11:23am UTC](https://discourse.julialang.org/t/julia-integral-calculation-community-module-or-own-module/24278 "2019-05-16T11:23:13Z")\
**Posts on this page:** 1\
**Showing post:** 15

<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:** [July 13, 2019, 10:28pm UTC](https://discourse.julialang.org/t/julia-integral-calculation-community-module-or-own-module/24278/15 "2019-07-13T22:28:50Z")

</div>

> [@wiktorkujawa](#):
>
> The problem is that quadgk return a tuple

You can always do `quadgk(...)[1]` to get the first element of the tuple (the integral) without assigning it to a variable.

Note also that `quadgk(u -> f(u), ...)` is equivalent to `quadgk(f, ...)`

Finally note that, If you are calculating `F(x) = quadgk(f, 0, x)` for a whole bunch of different values of `x ∈ [0,a]`, then there are _much_ more efficient things that you can do than separate `quadgk` integrals for each `x`, which wastes a _lot_ of calculations that could be shared between different `x` values, especially if `f(x)` is a smooth function. For example, using ApproxFun.jl, you can do `F = cumsum(Fun(f, 0..a))`, and then evaluate `F(x)` very quickly — this works by first constructing a polynomial approximation of `f(x)` on `[0,a]` and then forming the polynomial `F(x)` that is the indefinite integral.

---

_[View the full topic](https://discourse.julialang.org/t/julia-integral-calculation-community-module-or-own-module/24278)._
