# Using Bessel function in ROOT (posted for Sam Gregson)

**URL:** <https://root-forum.cern.ch/t/using-bessel-function-in-root-posted-for-sam-gregson/21020>\
**Category:** ROOT\
**Created:** [April 22, 2016, 3:07pm UTC](https://root-forum.cern.ch/t/using-bessel-function-in-root-posted-for-sam-gregson/21020 "2016-04-22T15:07:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hgordo](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/dc4da7/32.png) [@hgordo](https://root-forum.cern.ch/u/hgordo)\
**Post date:** [April 22, 2016, 3:07pm UTC](https://root-forum.cern.ch/t/using-bessel-function-in-root-posted-for-sam-gregson/21020/1 "2016-04-22T15:07:36Z")

</div>

Dear ROOT experts,

I wondered if I could ask you a quick question…

I am using ROOT 6.06/02 and trying to use a bessel function:

double skellam(double k, double mu1, double mu2) {  
return std::exp(-(mu1+mu2))_std::pow(mu1/mu2,0.5_k) \*  
ROOT::Math::cyl\_bessel\_i(std::abs(k), 2.0 \* std::sqrt(mu1\*mu2));  
}

However, when I compile my script in ROOT I see:

/home/sam/C\_Code/Peck\_Problem/./PeckMacro.C:151:70: error: no member named  
’cyl\_bessel\_i’ in namespace 'ROOT::Math’  
return std::exp(-(mu1+mu2))_std::pow(mu1/mu2,0.5_k) \* ROOT::Math::cyl\_b…

I did the following checks:

1. Checked mathmore was enabled - yes returned
2. Added #include  
"/home/sam/ROOT/root-6.06.02/math/mathmore/src/SpecFuncMathMore.cxx" to my  
script, but now I see:

In file included from /home/sam/C\_Code/Peck\_Problem/./PeckMacro.C:4:  
/home/sam/ROOT/root-6.06.02/math/mathmore/src/SpecFuncMathMore.cxx:20:10:  
fatal error:  
‘gsl/gsl\_sf\_bessel.h’ file not found  
#include “gsl/gsl\_sf\_bessel.h”  
^

I’m not sure what this means and don’t want to break any of the files.

Could you advise me please?

Thanks!

Sam

---

<div class="post-metadata">

**Author:** ![ExpectedValue](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/ecae2f/32.png) [@ExpectedValue](https://root-forum.cern.ch/u/ExpectedValue)\
**Post date:** [April 22, 2016, 3:29pm UTC](https://root-forum.cern.ch/t/using-bessel-function-in-root-posted-for-sam-gregson/21020/2 "2016-04-22T15:29:41Z")

</div>

I am now sign up - thanks Hamish! I’d appreciate any help, I’m sure I just need to link something else up.

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [April 22, 2016, 3:32pm UTC](https://root-forum.cern.ch/t/using-bessel-function-in-root-posted-for-sam-gregson/21020/3 "2016-04-22T15:32:18Z")

</div>

[code]#include “Math/SpecFunc.h”  
#include

double skellam(double k, double mu1, double mu2) {  
return std::exp(-(mu1 + mu2)) \* std::pow(mu1 / mu2, 0.5 \* k) \*  
ROOT::Math::cyl\_bessel\_i(std::abs(k), 2.0 \* std::sqrt(mu1 \* mu2));  
}[/code]

`root [0] gSystem->Load("libMathMore");
root [1] .L PeckMacro.C
root [2] skellam(1, 2, 3)`

---

<div class="post-metadata">

**Author:** ![ExpectedValue](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/ecae2f/32.png) [@ExpectedValue](https://root-forum.cern.ch/u/ExpectedValue)\
**Post date:** [April 22, 2016, 3:47pm UTC](https://root-forum.cern.ch/t/using-bessel-function-in-root-posted-for-sam-gregson/21020/4 "2016-04-22T15:47:44Z")

</div>

That got it! Thank you very much, Pepe 🙂

Sam
