I work with root now for some weeks, and went fine with the stuff I had to do (very basic things, so nothing complicated). But now it turned out, that there are some really basic functions missing for me:
First I’m missing the logarithm with the base e - how to get that? It should be obvious, I know, but I just don’t get it, and Root reference search was no help for me.
Second: I’m cofused by the fact that I can call functions like exp(1) and sqrt(5) on the command line to get results immediatly, but that I cannot get pi on this way - I have to write a simple function like
form1 = new TFormula("form1","pi*x");
root [78] form1->Eval(1);
root [79] form1->Eval(1)c to get the value of pi.
Why can’t I access pi on the command line, just as in functions?
If I just enter pi, I get pi
Error: Symbol pi is not defined in current scope FILE:(tmpfile) LINE:1
*** Interpreter error recovered ***
That’s confusing and a little bit annoying :-/
Third: these are stupid newbie questions, and I know that. I would like to save your and my time whenever I come up with such questions and therefore I would prefer using IRC for such stupid questions - is there an irc channel for ROOT?
Thank you very much for the answer, it helped a lot.
I also realized that the normal function log() which you can access directly is log in base e while I thought it is in base 10 (I’m used to log in base 10, lg also, but ln in base e).
[quote=“adrian_sev”]…
2)Double_t TMath::Log(Double_t x) in TMath.h[/quote]
I wanna to draw a function which includes “ln”, I wrote a program:
[code]#include “TMath.h” #include <math.h>
using namespace std;
int program(){
//Define Canvas
TCanvasc1=new TCanvas(“c1”,“c1 title”,1);
//Define function
TF1f1=new TF1(“f2”,"[0]+[1]*x+[2]/x+[3]*x^2+[4]*sin([5]/x)+[6]*Log(x)",0,110);
f1->SetParameter(0,3.37801e+00);
f1->SetParameter(1,-2.82399e-02);
f1->SetParameter(2,1.02849e+02);
f1->SetParameter(3,4.72812e-04);
f1->SetParameter(4,-2.73956e+02);
f1->SetParameter(5,-2.86744e+04);
f1->SetParameter(6,3);
f1->Draw();
}
[/code]
it’s my error:
Error in <TFormula::Compile>: Bad numerical expression : "Log(x)"
Error in <TF1::TF1>: function: f1/[0]+[1]*x+[2]/x+[3]*x^2+[4]*sin([5]/x)+[6]*Log(x) has 0 parameters instead of 1
Unknown function: f1