ROOT   Reference Guide
Searching...
No Matches
Legendre.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_math
3/// \notebook
4/// Example of first few Legendre Polynomials
5///
6/// Draws a graph.
7///
8/// \macro_image
9/// \macro_code
10///
11/// \author Lorenzo Moneta
12
13
14#include "TMath.h"
15#include "TF1.h"
16#include "TCanvas.h"
17
18#include <Riostream.h>
19#include "TLegend.h"
20#include "TLegendEntry.h"
21
22#include "Math/IFunction.h"
23#include <cmath>
24#include "TSystem.h"
25
26
27void Legendre()
28{
29 TCanvas *Canvas = new TCanvas("DistCanvas", "Legendre polynomials example", 10, 10, 750, 600);
30 Canvas->SetGrid();
31 TLegend *leg = new TLegend(0.5, 0.7, 0.4, 0.89);
32 //drawing the set of Legendre functions
33 TF1* L[5];
34 for(int nu = 0; nu <= 4; nu++)
35 {
36 L[nu]= new TF1("L_0", "ROOT::Math::legendre([0],x)", -1, 1);
37 L[nu]->SetParameters(nu, 0.0);
38 L[nu]->SetLineStyle(1);
39 L[nu]->SetLineWidth(2);
40 L[nu]->SetLineColor(nu+1);
41 }
42 L[0]->SetMaximum(1);
43 L[0]->SetMinimum(-1);
44 L[0]->SetTitle("Legendre polynomials");
50 leg->Draw();
51
52 Canvas->cd();
53}
The Canvas class.
Definition TCanvas.h:23
Definition TCanvas.cxx:719
1-Dim function class
Definition TF1.h:233
This class displays a legend box (TPaveText) containing several legend entries.
Definition TLegend.h:23
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:274
void SetGrid(Int_t valuex=1, Int_t valuey=1) override