# Integration of function with discontinuities given as vector elements with "quadgk"?

**URL:** https://discourse.julialang.org/t/integration-of-function-with-discontinuities-given-as-vector-elements-with-quadgk/47629
**Category:** New to Julia
**Tags:** question
**Created:** [October 2, 2020, 7:14am UTC](https://discourse.julialang.org/t/integration-of-function-with-discontinuities-given-as-vector-elements-with-quadgk/47629 "2020-10-02T07:14:26Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![hainzl](https://avatars.discourse-cdn.com/v4/letter/h/a88e4f/32.png) [@hainzl](https://discourse.julialang.org/u/hainzl)
#### Post date: [October 2, 2020, 7:14am UTC](https://discourse.julialang.org/t/integration-of-function-with-discontinuities-given-as-vector-elements-with-quadgk/47629/1 "2020-10-02T07:14:26Z")

</div>

I want to integrate a function f, which has discontinuities at the positions given as vector elements x[i] (the length of the vector and its values depends on the particular data set).

I know the “quadgk” offers the possibility for introducing such intermediate interval boundaries at dislocations with the convention:  
quadgk(function, x1, x2, x3…; kws…), where the function is integrated from x1 to x2, then from x2 to x3 and so on.  
However, the quadgk does not accept boundaries given as vector x such as  
quadgk(function, x; kws…)  
which gives the error message that it does not fit to the method quadgk(::Any, ::Any, ::Any, ::Any…; kws…).

I don‘t know how to deal with it … probably there is a simple solution to „translate“ my vector elements into the required format, which I don‘t know because it‘s only my second day with julia … can anybody help me?

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [October 2, 2020, 7:22am UTC](https://discourse.julialang.org/t/integration-of-function-with-discontinuities-given-as-vector-elements-with-quadgk/47629/2 "2020-10-02T07:22:35Z")

</div>

From your description it sounds like `quadgk(f, x...)`  
should work, where `x` is your vector and you literally type the three dots.

This is called “splatting”. It expands your vector into independent arguments of the function.

---

<div class="post-metadata">

### Author: ![hainzl](https://avatars.discourse-cdn.com/v4/letter/h/a88e4f/32.png) [@hainzl](https://discourse.julialang.org/u/hainzl)
#### Post date: [October 2, 2020, 8:21am UTC](https://discourse.julialang.org/t/integration-of-function-with-discontinuities-given-as-vector-elements-with-quadgk/47629/3 "2020-10-02T08:21:59Z")

</div>

Great, thanks a lot, it seems to work!

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [October 2, 2020, 1:21pm UTC](https://discourse.julialang.org/t/integration-of-function-with-discontinuities-given-as-vector-elements-with-quadgk/47629/4 "2020-10-02T13:21:32Z")

</div>

Glad it worked. Welcome to Julia and this Discourse site!

By the way, you can wrap code in backticks (```).
