Pi, ln() and irc


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?


1)root [0] TMath::Pi()
2)Double_t TMath::Log(Double_t x) in TMath.h

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).

Thanks again for the quick and detailed answer.


Hey rooters

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
f1=new TF1(“f2”,"[0]+[1]*x+[2]/x+[3]*x^2+[4]*sin([5]/x)+[6]*Log(x)",0,110);
it’s my error: :confused:

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

Could you help me?

TF1*f1=new TF1(“f2”,"[0]+[1]*x+[2]/x+[3]*x^2+[4]*sin([5]/x)+[6]TMath::Log(x)",0,110);
f1=new TF1(“f2”,"[0]+[1]*x+[2]/x+[3]*x^2+[4]*sin([5]/x)+[6]*log(x)",0,110);

[quote=“Wile E. Coyote”]TF1*f1=new TF1(“f2”,"[0]+[1]*x+[2]/x+[3]*x^2+[4]*sin([5]/x)+[6]TMath::Log(x)",0,110);
f1=new TF1(“f2”,"[0]+[1]*x+[2]/x+[3]*x^2+[4]*sin([5]/x)+[6]*log(x)",0,110);[/quote]

thank you :slight_smile: