Logo ROOT   6.10/09
Reference Guide
ChebyshevPol.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_math
3 /// \notebook
4 /// Example of Chebyshev polynomials
5 /// using new TFormula pre-defined definitions of chebyshev polynomials
6 ///
7 /// \macro_image
8 /// \macro_code
9 ///
10 /// \author Lorenzo Moneta
11 
12 void ChebyshevPol() {
13 
14 
15  auto legend = new TLegend(0.88,0.4,1.,1.);
16 
17  int colors[] = { kRed, kRed+3, kMagenta, kMagenta+3, kBlue, kBlue+3, kCyan+3, kGreen, kGreen+3, kYellow, kOrange };
18 
19  for (int degree=0; degree <=10; ++degree) {
20  auto f1 = new TF1("f1",TString::Format("cheb%d",degree),-1,1);
21  // all parameters are zero apart from the one corresponding to the degree
22  f1->SetParameter(degree,1);
23  f1->SetLineColor( colors[degree]);
24  f1->SetMinimum(-1.2);
25  f1->SetMaximum(1.2);
26  TString opt = (degree == 0) ? "" : "same";
27  //f1->Print("V");
28  f1->SetNpx(1000);
29  f1->SetTitle("Chebyshev Polynomial");
30  f1->Draw(opt);
31  legend->AddEntry(f1,TString::Format("N=%d",degree),"L");
32  }
33  legend->Draw();
34 }
35 
virtual void SetNpx(Int_t npx=100)
Set the number of points used to draw the function.
Definition: TF1.cxx:3202
This class displays a legend box (TPaveText) containing several legend entries.
Definition: TLegend.h:23
Definition: Rtypes.h:56
virtual void Draw(Option_t *option="")
Draw this legend with its current attributes.
Definition: TLegend.cxx:452
Basic string class.
Definition: TString.h:129
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
Definition: TF1.cxx:1087
Definition: Rtypes.h:56
Definition: Rtypes.h:56
virtual void SetMinimum(Double_t minimum=-1111)
Set the minimum value along Y for this function In case the function is already drawn, set also the minimum in the helper histogram.
Definition: TF1.cxx:3176
TLegend * legend
Definition: pirndm.C:35
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2345
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
virtual void SetMaximum(Double_t maximum=-1111)
Set the maximum value along Y for this function In case the function is already drawn, set also the maximum in the helper histogram.
Definition: TF1.cxx:3163
virtual void SetTitle(const char *title="")
Set function title if title has the form "fffffff;xxxx;yyyy", it is assumed that the function title i...
Definition: TF1.cxx:3315
Color * colors
Definition: X3DBuffer.c:19
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
Definition: TLegend.cxx:359
Definition: Rtypes.h:56
1-Dim function class
Definition: TF1.h:150
TF1 * f1
Definition: legend1.C:11
Definition: Rtypes.h:56
virtual void SetParameter(Int_t param, Double_t value)
Definition: TF1.h:578
Definition: Rtypes.h:57