37 R__LOAD_LIBRARY(libMathMore);
39 std::cout <<
"Drawing associate Legendre Polynomials.." << std::endl;
40 TCanvas *Canvas =
new TCanvas(
"DistCanvas",
"Associate Legendre polynomials", 10, 10, 800, 500);
42 TLegend *leg1 =
new TLegend(0.5, 0.7, 0.8, 0.89);
43 TLegend *leg2 =
new TLegend(0.5, 0.7, 0.8, 0.89);
49 L[0]=
new TF1(
"L_0",
"ROOT::Math::assoc_legendre(1, 0,x)", -1, 1);
50 L[1]=
new TF1(
"L_1",
"ROOT::Math::assoc_legendre(1, 1,x)", -1, 1);
51 L[2]=
new TF1(
"L_2",
"ROOT::Math::assoc_legendre(2, 0,x)", -1, 1);
52 L[3]=
new TF1(
"L_3",
"ROOT::Math::assoc_legendre(2, 1,x)", -1, 1);
53 L[4]=
new TF1(
"L_4",
"ROOT::Math::assoc_legendre(2, 2,x)", -1, 1);
57 SL[0]=
new TF1(
"SL_0",
"ROOT::Math::sph_legendre(1, 0,x)", -TMath::Pi(), TMath::Pi());
58 SL[1]=
new TF1(
"SL_1",
"ROOT::Math::sph_legendre(1, 1,x)", -TMath::Pi(), TMath::Pi());
59 SL[2]=
new TF1(
"SL_2",
"ROOT::Math::sph_legendre(2, 0,x)", -TMath::Pi(), TMath::Pi());
60 SL[3]=
new TF1(
"SL_3",
"ROOT::Math::sph_legendre(2, 1,x)", -TMath::Pi(), TMath::Pi());
61 SL[4]=
new TF1(
"SL_4",
"ROOT::Math::sph_legendre(2, 2,x)", -TMath::Pi(), TMath::Pi() );
65 gPad->SetFillColor(kWhite);
68 L[0]->SetTitle(
"Associate Legendre Polynomials");
69 for (
int nu = 0; nu < 5; nu++) {
70 L[nu]->SetLineStyle(1);
71 L[nu]->SetLineWidth(2);
72 L[nu]->SetLineColor(nu+1);
75 leg1->AddEntry(L[0]->DrawCopy(),
" P^{1}_{0}(x)",
"l");
76 leg1->AddEntry(L[1]->DrawCopy(
"same"),
" P^{1}_{1}(x)",
"l");
77 leg1->AddEntry(L[2]->DrawCopy(
"same"),
" P^{2}_{0}(x)",
"l");
78 leg1->AddEntry(L[3]->DrawCopy(
"same"),
" P^{2}_{1}(x)",
"l");
79 leg1->AddEntry(L[4]->DrawCopy(
"same"),
" P^{2}_{2}(x)",
"l");
84 gPad->SetFillColor(kWhite);
86 SL[0]->SetMinimum(-1);
87 SL[0]->SetTitle(
"Spherical Legendre Polynomials");
88 for (
int nu = 0; nu < 5; nu++) {
89 SL[nu]->SetLineStyle(1);
90 SL[nu]->SetLineWidth(2);
91 SL[nu]->SetLineColor(nu+1);
94 leg2->AddEntry(SL[0]->DrawCopy(),
" P^{1}_{0}(x)",
"l");
95 leg2->AddEntry(SL[1]->DrawCopy(
"same"),
" P^{1}_{1}(x)",
"l");
96 leg2->AddEntry(SL[2]->DrawCopy(
"same"),
" P^{2}_{0}(x)",
"l");
97 leg2->AddEntry(SL[3]->DrawCopy(
"same"),
" P^{2}_{1}(x)",
"l");
98 leg2->AddEntry(SL[4]->DrawCopy(
"same"),
" P^{2}_{2}(x)",
"l");
104 std::cout <<
"Calculating integrals of Associate Legendre Polynomials on [-1, 1]" << std::endl;
106 for (
int nu = 0; nu < 5; nu++) {
107 integral[nu] = L[nu]->Integral(-1.0, 1.0);
108 std::cout <<
"Integral [-1,1] for Associated Legendre Polynomial of Degree " << nu <<
"\t = \t" << integral[nu] << std::endl;