Logo ROOT   6.12/06
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Namespaces
Legendre.py File Reference

Namespaces

 Legendre
 

Detailed Description

Example of first few Legendre Polynomials.

Inspired by work of Lorenzo Moneta.

pict1_Legendre.py.png
1 
2 
3 import ROOT
4 
5 ROOT.gSystem.Load("libMathMore")
6 Canvas = ROOT.TCanvas("DistCanvas", "Legendre polynomials example", 10, 10, 750, 600)
7 Canvas.SetGrid()
8 leg = ROOT.TLegend(0.5, 0.7, 0.4, 0.89)
9 
10 L = []
11 for nu in range(5):
12  f = ROOT.TF1("L_0", "ROOT::Math::legendre([0],x)", -1, 1)
13  f.SetParameters(nu, 0.0)
14  f.SetLineStyle(1)
15  f.SetLineWidth(2)
16  f.SetLineColor(nu+1)
17  L.append(f)
18 
19 L[0].SetMaximum(1)
20 L[0].SetMinimum(-1)
21 L[0].SetTitle("Legendre polynomials")
22 leg.AddEntry(L[0].Draw(), " L_{0}(x)", "l")
23 leg.AddEntry(L[1].Draw("same"), " L_{1}(x)", "l")
24 leg.AddEntry(L[2].Draw("same"), " L_{2}(x)", "l")
25 leg.AddEntry(L[3].Draw("same"), " L_{3}(x)", "l")
26 leg.AddEntry(L[4].Draw("same"), " L_{4}(x)", "l")
27 leg.Draw()
28 
29 
Author
Alberto Ferro

Definition in file Legendre.py.