Show the different kinds of Bessel functions available in ROOT To execute the macro type in:
It will create one canvas with the representation of the cylindrical and spherical Bessel functions regular and modified
#include <cmath>
{
TCanvas *DistCanvas =
new TCanvas(
"DistCanvas",
"Bessel functions example", 10, 10, 800, 600);
gPad->SetFrameFillColor(19);
int n = 5;
for(
int nu = 0; nu <
n; nu++)
{
JBessel[nu]=
new TF1(
"J_0",
"ROOT::Math::cyl_bessel_j([0],x)", 0, 10);
}
JBessel[0]->TF1::GetXaxis()->
SetTitle(
"x");
leg->
AddEntry(JBessel[0]->DrawCopy(),
" J_0(x)",
"l");
leg->
AddEntry(JBessel[1]->DrawCopy(
"same"),
" J_1(x)",
"l");
leg->
AddEntry(JBessel[2]->DrawCopy(
"same"),
" J_2(x)",
"l");
leg->
AddEntry(JBessel[3]->DrawCopy(
"same"),
" J_3(x)",
"l");
leg->
AddEntry(JBessel[4]->DrawCopy(
"same"),
" J_4(x)",
"l");
gPad->SetFrameFillColor(19);
for(
int nu = 0; nu <
n; nu++){
KBessel[nu]=
new TF1(
"J_0",
"ROOT::Math::cyl_bessel_k([0],x)", 0, 10);
KBessel[nu]->
SetTitle(
"Bessel K functions");
}
leg2->
AddEntry(KBessel[0]->DrawCopy(),
" K_0(x)",
"l");
leg2->
AddEntry(KBessel[1]->DrawCopy(
"same"),
" K_1(x)",
"l");
leg2->
AddEntry(KBessel[2]->DrawCopy(
"same"),
" K_2(x)",
"l");
leg2->
AddEntry(KBessel[3]->DrawCopy(
"same"),
" K_3(x)",
"l");
leg2->
AddEntry(KBessel[4]->DrawCopy(
"same"),
" K_4(x)",
"l");
gPad->SetFrameFillColor(19);
for(int nu = 0; nu <= 4; nu++){
iBessel[nu]=
new TF1(
"J_0",
"ROOT::Math::cyl_bessel_i([0],x)", 0, 10);
iBessel[nu]->
SetTitle(
"Bessel I functions");
}
leg3->
AddEntry(iBessel[0]->DrawCopy(),
" I_0",
"l");
leg3->
AddEntry(iBessel[1]->DrawCopy(
"same"),
" I_1(x)",
"l");
leg3->
AddEntry(iBessel[2]->DrawCopy(
"same"),
" I_2(x)",
"l");
leg3->
AddEntry(iBessel[3]->DrawCopy(
"same"),
" I_3(x)",
"l");
leg3->
AddEntry(iBessel[4]->DrawCopy(
"same"),
" I_4(x)",
"l");
gPad->SetFrameFillColor(19);
for(int nu = 0; nu <= 4; nu++){
jBessel[nu]=
new TF1(
"J_0",
"ROOT::Math::sph_bessel([0],x)", 0, 10);
jBessel[nu]->
SetTitle(
"Bessel j functions");
}
leg4->
AddEntry(jBessel[0]->DrawCopy(),
" j_0(x)",
"l");
leg4->
AddEntry(jBessel[1]->DrawCopy(
"same"),
" j_1(x)",
"l");
leg4->
AddEntry(jBessel[2]->DrawCopy(
"same"),
" j_2(x)",
"l");
leg4->
AddEntry(jBessel[3]->DrawCopy(
"same"),
" j_3(x)",
"l");
leg4->
AddEntry(jBessel[4]->DrawCopy(
"same"),
" j_4(x)",
"l");
}
- Author
- Magdalena Slawinska
Definition in file Bessel.C.