Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ChebyshevPol.C File Reference

Detailed Description

View in nbviewer Open in SWAN
Example of Chebyshev polynomials using new TFormula pre-defined definitions of chebyshev polynomials

void ChebyshevPol() {
auto legend = new TLegend(0.88,0.4,1.,1.);
for (int degree=0; degree <=10; ++degree) {
auto f1 = new TF1("f1",TString::Format("cheb%d",degree),-1,1);
// all parameters are zero apart from the one corresponding to the degree
f1->SetParameter(degree,1);
f1->SetLineColor( colors[degree]);
f1->SetMinimum(-1.2);
f1->SetMaximum(1.2);
TString opt = (degree == 0) ? "" : "same";
//f1->Print("V");
f1->SetNpx(1000);
f1->SetTitle("Chebyshev Polynomial");
f1->Draw(opt);
legend->AddEntry(f1,TString::Format("N=%d",degree),"L");
}
legend->Draw();
}
@ kRed
Definition Rtypes.h:66
@ kOrange
Definition Rtypes.h:67
@ kGreen
Definition Rtypes.h:66
@ kMagenta
Definition Rtypes.h:66
@ kCyan
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
@ kYellow
Definition Rtypes.h:66
Color * colors
Definition X3DBuffer.c:21
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:40
1-Dim function class
Definition TF1.h:214
virtual void SetMaximum(Double_t maximum=-1111)
Set the maximum value along Y for this function In case the function is already drawn,...
Definition TF1.cxx:3394
void SetTitle(const char *title="") override
Set function title if title has the form "fffffff;xxxx;yyyy", it is assumed that the function title i...
Definition TF1.cxx:3552
virtual void SetNpx(Int_t npx=100)
Set the number of points used to draw the function.
Definition TF1.cxx:3433
void Draw(Option_t *option="") override
Draw this function with its current attributes.
Definition TF1.cxx:1335
virtual void SetMinimum(Double_t minimum=-1111)
Set the minimum value along Y for this function In case the function is already drawn,...
Definition TF1.cxx:3407
virtual void SetParameter(Int_t param, Double_t value)
Definition TF1.h:640
This class displays a legend box (TPaveText) containing several legend entries.
Definition TLegend.h:23
Basic string class.
Definition TString.h:139
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:2356
TF1 * f1
Definition legend1.C:11
Author
Lorenzo Moneta

Definition in file ChebyshevPol.C.