00001
00002
00003
00004 #if defined(__CINT__) && !defined(__MAKECINT__)
00005 {
00006 gSystem->CompileMacro("Legendre.C", "k");
00007 Legendre();
00008 }
00009 #else
00010
00011 #include "TMath.h"
00012 #include "TF1.h"
00013 #include "TCanvas.h"
00014
00015 #include <Riostream.h>
00016 #include "TLegend.h"
00017 #include "TLegendEntry.h"
00018
00019 #include "Math/IFunction.h"
00020 #include <cmath>
00021 #include "TSystem.h"
00022
00023
00024 void Legendre()
00025 {
00026 gSystem->Load("libMathMore");
00027
00028 TCanvas *Canvas = new TCanvas("DistCanvas", "Legendre polynomials example", 10, 10, 750, 600);
00029 Canvas->SetFillColor(17);
00030 Canvas->SetGrid();
00031 Canvas->SetFrameFillColor(19);
00032 TLegend *leg = new TLegend(0.5, 0.7, 0.4, 0.89);
00033
00034
00035
00036 TF1* L[5];
00037 for(int nu = 0; nu <= 4; nu++)
00038 {
00039 L[nu]= new TF1("L_0", "ROOT::Math::legendre([0],x)", -1, 1);
00040 L[nu]->SetParameters(nu, 0.0);
00041 L[nu]->SetLineStyle(1);
00042 L[nu]->SetLineWidth(2);
00043 L[nu]->SetLineColor(nu+1);
00044 }
00045 L[0]->SetMaximum(1);
00046 L[0]->SetMinimum(-1);
00047 L[0]->SetTitle("Legendre polynomials");
00048 leg->AddEntry(L[0]->DrawCopy(), " L_{0}(x)", "l");
00049 leg->AddEntry(L[1]->DrawCopy("same"), " L_{1}(x)", "l");
00050 leg->AddEntry(L[2]->DrawCopy("same"), " L_{2}(x)", "l");
00051 leg->AddEntry(L[3]->DrawCopy("same"), " L_{3}(x)", "l");
00052 leg->AddEntry(L[4]->DrawCopy("same"), " L_{4}(x)", "l");
00053 leg->Draw();
00054
00055 Canvas->cd();
00056
00057 }
00058
00059 #endif
00060
00061