# How do I do a fast cumulative integration

**URL:** <https://discourse.julialang.org/t/how-do-i-do-a-fast-cumulative-integration/85574>\
**Category:** Numerics\
**Tags:** integral\
**Created:** [August 10, 2022, 8:27am UTC](https://discourse.julialang.org/t/how-do-i-do-a-fast-cumulative-integration/85574 "2022-08-10T08:27:16Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![tobydriscoll](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobydriscoll/32/1843_2.png) [@tobydriscoll](https://discourse.julialang.org/u/tobydriscoll)\
**Post date:** [August 10, 2022, 2:21pm UTC](https://discourse.julialang.org/t/how-do-i-do-a-fast-cumulative-integration/85574/5 "2022-08-10T14:21:38Z")

</div>

[ApproxFun](https://juliaapproximation.github.io/ApproxFun.jl/stable/) does this:

```julia
julia> f = Fun(x->exp(-x^2),0..5);

julia> g = 2/sqrt(π)*integrate(f); h = g - g(0);

julia> x = 0:0.5:5; [f.(x) h.(x)]
11×2 Matrix{Float64}:
 1.0 0.0
 0.778801 0.5205
 0.367879 0.842701
 0.105399 0.966105
 0.0183156 0.995322
 0.00193045 0.999593
 0.00012341 0.999978
 4.78512e-6 0.999999
 1.12535e-7 1.0
 1.60523e-9 1.0
 1.3888e-11 1.0

```

For a univariate function, I doubt you will be able to do much better.

---

_[View the full topic](https://discourse.julialang.org/t/how-do-i-do-a-fast-cumulative-integration/85574)._
