ROOT logo

From $ROOTSYS/tutorials/math/Bessel.C

// Show the different kinds of Bessel functions available in ROOT 
// To execute the macro type in:
//
// root[0]: .x Bessel.C 
//
// It will create one canvas with the representation 
// of the  cylindrical and spherical Bessel functions
// regular and modified

//
//  Author: Magdalena Slawinska

#include "TMath.h"
#include "TF1.h"
#include "TCanvas.h"

#include <Riostream.h>
#include "TLegend.h"
#include "TLegendEntry.h"

#include "Math/IFunction.h"
#include <cmath>
#include "TSystem.h"
#include "TAxis.h"
#include "TPaveLabel.h"

void Bessel()
{
  gSystem->Load("libMathMore");

  TCanvas *DistCanvas = new TCanvas("DistCanvas", 
     "Bessel functions example", 10, 10, 1000, 800);  
  DistCanvas->SetFillColor(17);
  DistCanvas->Divide(2, 2);
  DistCanvas->cd(1);
  gPad->SetGrid();
  gPad->SetFrameFillColor(19);
  TLegend *leg = new TLegend(0.75, 0.7, 0.89, 0.89); 

  int n = 5;//number of functions in each pad
//drawing the set of Bessel J functions   
  TF1* JBessel[5];
  for(int nu = 0; nu < n; nu++)
  {
      JBessel[nu]= new TF1("J_0", "ROOT::Math::cyl_bessel_j([0],x)", 0, 10);
      JBessel[nu]->SetParameters(nu, 0.0);
      JBessel[nu]->SetTitle("");//Bessel J functions");  
      JBessel[nu]->SetLineStyle(1);
      JBessel[nu]->SetLineWidth(3);
      JBessel[nu]->SetLineColor(nu+1);
  }
  JBessel[0]->TF1::GetXaxis()->SetTitle("x");
  JBessel[0]->GetXaxis()->SetTitleSize(0.06);
  JBessel[0]->GetXaxis()->SetTitleOffset(.7);

  //setting the title in a label style
  TPaveLabel *p1 = new TPaveLabel(.0,.90 , (.0+.50),(.90+.10) ,
     "Bessel J functions", "NDC");
p1->SetFillColor(0);
p1->SetTextFont(22);
p1->SetTextColor(kBlack);

//setting the legend
  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");

  leg->Draw();
  p1->Draw();

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   DistCanvas->cd(2);
   gPad->SetGrid();
   gPad->SetFrameFillColor(19);

   TLegend *leg2 = new TLegend(0.75, 0.7, 0.89, 0.89); 
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//Drawing Bessel k  
   TF1* KBessel[5];
   for(int nu = 0; nu < n; nu++)
    {
      KBessel[nu]= new TF1("J_0", "ROOT::Math::cyl_bessel_k([0],x)", 0, 10);
      KBessel[nu]->SetParameters(nu, 0.0);
      KBessel[nu]->SetTitle("Bessel K functions");  
      KBessel[nu]->SetLineStyle(1);
      KBessel[nu]->SetLineWidth(3);
      KBessel[nu]->SetLineColor(nu+1);
    }
    KBessel[0]->GetXaxis()->SetTitle("x");
    KBessel[0]->GetXaxis()->SetTitleSize(0.06);
    KBessel[0]->GetXaxis()->SetTitleOffset(.7);

    //setting title
    TPaveLabel *p2 = new TPaveLabel(.0,.90 , (.0+.50),(.90+.10) ,
       "Bessel K functions", "NDC");
    p2->SetFillColor(0);
    p2->SetTextFont(22);
    p2->SetTextColor(kBlack);

    //setting legend
    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");
//   for(int nu = 1; nu <= 4; nu++)
//   leg->AddEntry(JBessel[0]->DrawCopy("lsame"), "", "l");
  

    leg2->Draw();
    p2->Draw();
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   DistCanvas->cd(3);
   gPad->SetGrid();
   gPad->SetFrameFillColor(19);
   TLegend *leg3 = new TLegend(0.75, 0.7, 0.89, 0.89); 
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 //Drawing Bessel i     
   TF1* iBessel[5];
   for(int nu = 0; nu <= 4; nu++)
    {
      iBessel[nu]= new TF1("J_0", "ROOT::Math::cyl_bessel_i([0],x)", 0, 10);
      iBessel[nu]->SetParameters(nu, 0.0);
      iBessel[nu]->SetTitle("Bessel I functions");  
      iBessel[nu]->SetLineStyle(1);
      iBessel[nu]->SetLineWidth(3);
      iBessel[nu]->SetLineColor(nu+1);
    }

    iBessel[0]->GetXaxis()->SetTitle("x");   
    iBessel[0]->GetXaxis()->SetTitleSize(0.06);
    iBessel[0]->GetXaxis()->SetTitleOffset(.7);

    //setting title
    TPaveLabel *p3 = new TPaveLabel(.0,.90 , (.0+.50),(.90+.10) ,
       "Bessel I functions", "NDC");
    p3->SetFillColor(0);
    p3->SetTextFont(22);
    p3->SetTextColor(kBlack);

    //setting legend
    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");
//   for(int nu = 1; nu <= 4; nu++)
//   leg->AddEntry(JBessel[0]->DrawCopy("lsame"), "", "l");
  
    //iBessel[0]->Draw();
    leg3->Draw();
    p3->Draw();
 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

   DistCanvas->cd(4);
   gPad->SetGrid();
   gPad->SetFrameFillColor(19);
   TLegend *leg4 = new TLegend(0.75, 0.7, 0.89, 0.89); 

  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   //drawing sph_bessel
   TF1* jBessel[5];
   for(int nu = 0; nu <= 4; nu++)
   {
      jBessel[nu]= new TF1("J_0", "ROOT::Math::sph_bessel([0],x)", 0, 10);
      jBessel[nu]->SetParameters(nu, 0.0);
      jBessel[nu]->SetTitle("Bessel j functions");  
      jBessel[nu]->SetLineStyle(1);
      jBessel[nu]->SetLineWidth(3);
      jBessel[nu]->SetLineColor(nu+1);
   }
    jBessel[0]->GetXaxis()->SetTitle("x");   
    jBessel[0]->GetXaxis()->SetTitleSize(0.06);
    jBessel[0]->GetXaxis()->SetTitleOffset(.7);

    //setting title
    TPaveLabel *p4 = new TPaveLabel(.0,.90 , (.0+.50),(.90+.10) ,
       "Bessel j functions", "NDC");
    p4->SetFillColor(0);
    p4->SetTextFont(22);
    p4->SetTextColor(kBlack);

    //setting legend

    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");

    leg4->Draw();
    p4->Draw();
 
    DistCanvas->cd();
}


 Bessel.C:1
 Bessel.C:2
 Bessel.C:3
 Bessel.C:4
 Bessel.C:5
 Bessel.C:6
 Bessel.C:7
 Bessel.C:8
 Bessel.C:9
 Bessel.C:10
 Bessel.C:11
 Bessel.C:12
 Bessel.C:13
 Bessel.C:14
 Bessel.C:15
 Bessel.C:16
 Bessel.C:17
 Bessel.C:18
 Bessel.C:19
 Bessel.C:20
 Bessel.C:21
 Bessel.C:22
 Bessel.C:23
 Bessel.C:24
 Bessel.C:25
 Bessel.C:26
 Bessel.C:27
 Bessel.C:28
 Bessel.C:29
 Bessel.C:30
 Bessel.C:31
 Bessel.C:32
 Bessel.C:33
 Bessel.C:34
 Bessel.C:35
 Bessel.C:36
 Bessel.C:37
 Bessel.C:38
 Bessel.C:39
 Bessel.C:40
 Bessel.C:41
 Bessel.C:42
 Bessel.C:43
 Bessel.C:44
 Bessel.C:45
 Bessel.C:46
 Bessel.C:47
 Bessel.C:48
 Bessel.C:49
 Bessel.C:50
 Bessel.C:51
 Bessel.C:52
 Bessel.C:53
 Bessel.C:54
 Bessel.C:55
 Bessel.C:56
 Bessel.C:57
 Bessel.C:58
 Bessel.C:59
 Bessel.C:60
 Bessel.C:61
 Bessel.C:62
 Bessel.C:63
 Bessel.C:64
 Bessel.C:65
 Bessel.C:66
 Bessel.C:67
 Bessel.C:68
 Bessel.C:69
 Bessel.C:70
 Bessel.C:71
 Bessel.C:72
 Bessel.C:73
 Bessel.C:74
 Bessel.C:75
 Bessel.C:76
 Bessel.C:77
 Bessel.C:78
 Bessel.C:79
 Bessel.C:80
 Bessel.C:81
 Bessel.C:82
 Bessel.C:83
 Bessel.C:84
 Bessel.C:85
 Bessel.C:86
 Bessel.C:87
 Bessel.C:88
 Bessel.C:89
 Bessel.C:90
 Bessel.C:91
 Bessel.C:92
 Bessel.C:93
 Bessel.C:94
 Bessel.C:95
 Bessel.C:96
 Bessel.C:97
 Bessel.C:98
 Bessel.C:99
 Bessel.C:100
 Bessel.C:101
 Bessel.C:102
 Bessel.C:103
 Bessel.C:104
 Bessel.C:105
 Bessel.C:106
 Bessel.C:107
 Bessel.C:108
 Bessel.C:109
 Bessel.C:110
 Bessel.C:111
 Bessel.C:112
 Bessel.C:113
 Bessel.C:114
 Bessel.C:115
 Bessel.C:116
 Bessel.C:117
 Bessel.C:118
 Bessel.C:119
 Bessel.C:120
 Bessel.C:121
 Bessel.C:122
 Bessel.C:123
 Bessel.C:124
 Bessel.C:125
 Bessel.C:126
 Bessel.C:127
 Bessel.C:128
 Bessel.C:129
 Bessel.C:130
 Bessel.C:131
 Bessel.C:132
 Bessel.C:133
 Bessel.C:134
 Bessel.C:135
 Bessel.C:136
 Bessel.C:137
 Bessel.C:138
 Bessel.C:139
 Bessel.C:140
 Bessel.C:141
 Bessel.C:142
 Bessel.C:143
 Bessel.C:144
 Bessel.C:145
 Bessel.C:146
 Bessel.C:147
 Bessel.C:148
 Bessel.C:149
 Bessel.C:150
 Bessel.C:151
 Bessel.C:152
 Bessel.C:153
 Bessel.C:154
 Bessel.C:155
 Bessel.C:156
 Bessel.C:157
 Bessel.C:158
 Bessel.C:159
 Bessel.C:160
 Bessel.C:161
 Bessel.C:162
 Bessel.C:163
 Bessel.C:164
 Bessel.C:165
 Bessel.C:166
 Bessel.C:167
 Bessel.C:168
 Bessel.C:169
 Bessel.C:170
 Bessel.C:171
 Bessel.C:172
 Bessel.C:173
 Bessel.C:174
 Bessel.C:175
 Bessel.C:176
 Bessel.C:177
 Bessel.C:178
 Bessel.C:179
 Bessel.C:180
 Bessel.C:181
 Bessel.C:182
 Bessel.C:183
 Bessel.C:184
 Bessel.C:185
 Bessel.C:186
 Bessel.C:187
 Bessel.C:188
 Bessel.C:189
 Bessel.C:190
 Bessel.C:191
 Bessel.C:192
 Bessel.C:193
 Bessel.C:194
 Bessel.C:195
 Bessel.C:196
 Bessel.C:197
 Bessel.C:198
 Bessel.C:199
 Bessel.C:200
thumb

相关内容推荐

免费的动态壁纸呱聊ai软件免费下载应用宝app下载手机驱动程序塞拉七号反应力训练游戏大尺度直播平台互动游戏超级玛丽下载神途手游总登录器王者荣耀老版本美图秀秀旧版celluar悦色app战舰世界传奇去哪儿旅游网wsgjp驾驶学校2017日在校园无删减版拼拼乐heroism迷你世界跑酷白秘书拼拼乐范特西篮球中移网大网页版暴风影音官方赛车漂移夜猫app契约ol快看影视app冰火大作战百度小说网迷你世界枪战精英串口调试软件英雄的黎明极速电影网小黄车ofo绅士学院智慧记官网像素精灵微信分身2迅雷种子搜索器狐仙传微信平板fr传奇破解版下载音乐软件魔力四射学车堂世界大战英雄melody下载绿茵传奇省钱神器全能音频转换器慧编程作品大人糖官网unciv冠军足球找茬游戏小红唇湖南电力青团社谷歌相机安装方法跑步控游道易两性用品商城七绝游戏可恶的小偷商贾云集锈铁战争森林王国保卫萝卜小小勇者砰砰军团有道翻译下载游戏动画手机坡度测量仪趣头条自媒体平台翠鲜缘qq邮箱官方一品团上海安达医院秘塔迅雷下载网花间月威尔士健身官网移动话费查询余额垂直采伏魔记91安卓逍遥游手游梦幻恋舞谷歌邮箱官网车小乙黑化徒弟养成攻略内蒙古市场监督名城苏州官网飞悦叉叉助手官网九阴手游吉途狐仙大人快吧游戏盒官网调谐器死神狂潮三级快播绝地生存下载明日之后渠道服六合图库公众号文章编辑器互动游戏抽奖软件口袋妖怪最强进化书宝网云犀思维实验室开罗拉面店终极驾驶天籁k歌搜狗拼音下载七麦比特精灵外聘网官网mirror下载永恒联盟鹦鹉模拟器韩国游戏排行榜智能电视软件合通火柴人快打快快影院同人软件红警之大国崛起甘肃社保翻译文言文的软件免费动漫app双人同行火线精英4399真实滑板下载看球吧appqq学生网官网游戏阁车机天地诸神日批软件会员管理火柴人部落qq版本升级美洽biblqq浏览器x86七天网络登录网上销售平台flash助手南京公积金查询圣儒星空帝国台球帝国下载我的世界单机下载香肠传奇郑州市教育博客破晓奇兵蜘蛛纸牌免费下载天翼视讯环形帝国照片修改器神奇动物园美食软件后宫游戏下载决战枭雄air游戏电竞比分京师学堂手机数据恢复软件陕西省社保海浪预报冰火人小游戏双人全面战争竞技场竞赛游戏修复照片台风预报海盗王好音乐ae下载手机版猎魔传奇cameravapp掌上悟空我爱斗地主龙珠z格斗河南省工商unciv万信达加油河南试玩平台长佩文学网页版电子医保卡武动乾坤手游游加速器

合作伙伴

冲顶技术团队

seo.chaoshanxing.com
www.chaoshanxing.com
www.jsfengchao.com
dh.jsfengchao.com
kuai.urkeji.com
zz.urkeji.com
www.mtcddc.cn
dw.urkeji.com
www.conductive-powder.com
www.hz.bj.cn
www.bjdongwei.cn
www.3phw.com
www.kmpower.cn
idc.urkeji.com
www.andmedia.cn
www.tjwyj.com
www.xm5656.cn
seo.urkeji.com
www.3phw.com
www.maijichuang.cn