Eval of Chebyshev Polynomials

Hello,

I am trying to do a quick calculation/simulation of Synchrotron radiation using root. The procedure is described in: H. Burkhardt, CERN-OPEN-2007-018 (and implemented in GEANT4).
To be able to do that, one must evaluate Chebyshev polynomials at a given value x, in range [a,b] and for a given set of coefficients - i.e.: Chebyshev(a,b,coeffs,n,x), n=number of coefficients.
Is there a call in root to do that? searched but could not find any. Or, is there an example of Synchrotron radiation in root?

Thank you very much.
Riad.

Googling “Chebyshev ROOT” gave me:

root.cern.ch/root/html/ROOT__Ma … yshev.html

Sorry, I should have been more specific. I am trying to evaluate the series for a given number; see attached macro file. But not sure how to do it.
Cheby.C (693 Bytes)

Hi,

The class defining the Chebyshev polynomial in ROOT is ROOT::Math::ChebyshevPol, see

root.cern.ch/root/html/ROOT__Ma … evPol.html

You can use them as TF1, they are already defined as predefined functions in gROOT as “chebyshevN”.
So for example for using a chebyshev polynomial of degree 4 you can do:

TF1 * f = (TF1*) gROOT->GetFunction("chebyshev4");
f->SetParameters(1,1,1,1);
f->Draw(); 

Best Regards

Lorenzo

Lorenzo forgot to mention a very tiny detail that “chebyshevN” work only in ROOT 6.

Hi,

No, they exists also in ROOT 5.34. The name is abbreviated in that case : “chebN” instead of “chebyshevN”.

Lorenzo

Thank you very much. It seems that “cheb4” is Chebyshev series - not polynomial. To get the polynomial one has to set: SetParameters(0,0,0,0,1) which givesT4 = 8x^4 - 8x^2 + 1. This is not a problem.

However, it seems only up to n=9 are defined; i.e., “cheb10” will not work:

root [0] TF1 * f = (TF1*) gROOT->GetFunction(“cheb10”);
root [1] f->Draw();
Error: illegal pointer to class object f 0x0 1205 (tmpfile):1:
*** Interpreter error recovered ***

Notices also that SetParameters only takes up to 10 parameters. So cannot access Chebyshev series above n=9. I needed n=30.

There is no “up to 11 parameters” limit if you use one of:
void TFormula::SetParameters(const Double_t* params)
void TFormula::SetParameter(Int_t ipar, Double_t parvalue)
void TFormula::SetParameter(const char* name, Double_t parvalue)

BTW. Note that “chebN” and “chebyshevN” exist for “N = 0, …, 9” only.

HI,

For larger number of parameters you can use directly the ROOT::Math::ChebyshevPol class :

      // example for n = 20
       const int n = 20;
       ROOT::Math::ChebyshevPol * pol = new ROOT::Math::ChebyshevPol(n);
        Double_t min = -1;
        Double_t max = 1;
        TF1 * f1 = new TF1(TString::Format("chebyshev%d",n),pol,min,max,n+1,1);
        double p[n] = {0};
        p[n-1] = 1; 
        f1->SetParameters(p);

Lorenzo