# Double integration with dependent bounds

**URL:** <https://root-forum.cern.ch/t/double-integration-with-dependent-bounds/54017>\
**Category:** ROOT\
**Created:** [March 14, 2023, 10:43am UTC](https://root-forum.cern.ch/t/double-integration-with-dependent-bounds/54017 "2023-03-14T10:43:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![morbik](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@morbik](https://root-forum.cern.ch/u/morbik)\
**Post date:** [March 14, 2023, 10:43am UTC](https://root-forum.cern.ch/t/double-integration-with-dependent-bounds/54017/1 "2023-03-14T10:43:31Z")

</div>

Dear all,

I am trying to calculate value of a integral with definite bounds but the integrand is another integral, and one of the bounds of this second integral is the variable of the first integral. I am attaching representative picture.

\int\_{9.5}^{10.5}dx\ x \int\_{1}^0 dy \ y

How I can write this as a function? Thank you soo much for your help.

Cheers,  
morbik

* * *

_ROOT Version:_ 6.24/16  
_Platform:_ mac os x 64  
_Compiler:_ clang 13.1.6

* * *

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [March 14, 2023, 10:47am UTC](https://root-forum.cern.ch/t/double-integration-with-dependent-bounds/54017/2 "2023-03-14T10:47:49Z")

</div>

> [@C++ doubts in global variables and numerical integration](https://root-forum.cern.ch/t/c-doubts-in-global-variables-and-numerical-integration/25124/2):
>
> See the old “[Boundary integral](https://root-forum.cern.ch/t/boundary-integral/17872/6)” and "[Non-rectangular region integration](https://root-forum.cern.ch/t/non-rectangular-region-integration/23765)" threads.

---

<div class="post-metadata">

**Author:** ![morbik](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@morbik](https://root-forum.cern.ch/u/morbik)\
**Post date:** [March 14, 2023, 2:03pm UTC](https://root-forum.cern.ch/t/double-integration-with-dependent-bounds/54017/3 "2023-03-14T14:03:35Z")

</div>

Dear @Wile_E_Coyote, thank you a lot for always replying. I have done the change of variables but actually it couldn’t solve my problem as far as understand. Maybe the representative function was too easy. My function is bit more complicated  
\int\_{9.5}^{10.5}da \frac{1}{x} \int\_{0}^{1}dt\ a\*t\*sin(x \int\_{1}^{0}dk\ a\*t\*k) \* sph\_bessel(x,x\*\int\_{1}^{0}dl\ a\*l)

I am aware this is too complicated maybe, but the thing is that I want to draw this function over x that extens from 0 to 1000, and hopefully at one point I want to do a fit with this function. And since I cannot just take all the integrals outside as in the case of other posts, I feel like I cannot do this with ROOT, would that be corrrect? Do you think I should try to do it with RooFit? I am completely open to any suggestions.

Cheers,  
morbik

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [March 14, 2023, 2:30pm UTC](https://root-forum.cern.ch/t/double-integration-with-dependent-bounds/54017/4 "2023-03-14T14:30:19Z")

</div>

[ROOT Manual → Functional parts → Mathematical libraries → MathCore library → Numerical integration](https://root.cern/manual/math/#numerical-integration)

---

<div class="post-metadata">

**Author:** ![morbik](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@morbik](https://root-forum.cern.ch/u/morbik)\
**Post date:** [March 14, 2023, 3:31pm UTC](https://root-forum.cern.ch/t/double-integration-with-dependent-bounds/54017/5 "2023-03-14T15:31:59Z")

</div>

Dear @Wile_E_Coyote,

I have checked all of thet page. But I think it doesn’t cover my problem. I am sorry if I am missing something. But the thing is, I cannot write my function as

\int\_{0}^1\int\_{0}^1\int\_{0}^1\int\_{0}^1dxdydzdt\ x \* y \* z \* t

it is more of the form

\int\_{9.5}^{10.5}da \frac{1}{x} \int\_{0}^{1}dt\ a\*t\*sin(x \int\_{1}^{0}dk\ a\*t\*k) \* sph\_bessel(x,x\*\int\_{1}^{0}dl\ a\*l)

Meaning that I cannot just say write down one integrate. Sorry if it is not clear, or if I am missing something very little.

Cheers,  
morbik

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [March 14, 2023, 3:42pm UTC](https://root-forum.cern.ch/t/double-integration-with-dependent-bounds/54017/6 "2023-03-14T15:42:55Z")

</div>

The integral over “`dl`” is just “`-a/2.`” and the integral over “`dk`” is just “`-a*t/2.`”.  
Possibly you could also “simplify” the remaining integrals → [WolframAlpha](https://www.wolframalpha.com/)

BTW. I don’t know what kind of variable “`x`” is ([“`sph_bessel`” expects an “`unsigned int`” as the first parameter and a non-negative “`double`” as the second parameter](https://root.cern.ch/doc/master/group__SpecFunc.html#gab97dd08d7ff5e79df843d01832dc4b00)).

---

<div class="post-metadata">

**Author:** ![morbik](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@morbik](https://root-forum.cern.ch/u/morbik)\
**Post date:** [March 14, 2023, 5:21pm UTC](https://root-forum.cern.ch/t/double-integration-with-dependent-bounds/54017/7 "2023-03-14T17:21:46Z")

</div>

Thank you a lot, but the thing is that integral I have written over here is representative. It is actually quite complicated. I cannot perform these integrals by hand easily, WolframAlpha exceeds the maximum integration time, and I have tried over Mathematica too but the result is too ugly to type to ROOT by hand all the time. And I will be doing many of them while I try to develop the theory.

Anyhow, I guess I will continue to think. Thank you so much again.

Cheers,  
morbik

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [March 16, 2023, 10:24am UTC](https://root-forum.cern.ch/t/double-integration-with-dependent-bounds/54017/8 "2023-03-16T10:24:32Z")

</div>

Just for completeness of this thread, see also: [“Integral with dependent bounds”](https://root-forum.cern.ch/t/integral-with-dependent-bounds/54028)

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [March 30, 2023, 10:24am UTC](https://root-forum.cern.ch/t/double-integration-with-dependent-bounds/54017/9 "2023-03-30T10:24:37Z")

</div>

Closed on March 30, 2023, 10:24am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
