Im plotting this sinc function(sin(x)/x) using TF1 class,
when I plot it for the short range it gives me the accurate result (value 1 at x=0).
but when I plot it for large range it gives me some strange plot, also the value at x=0 is not 1 now
please explain .
TF1 f1(“f1”, “sin(x)/x”,-10,10);
for large range
TF1 f1(“f1”, “sin(x)/x”,0,2000);
TF1 f1(“f1”, “sin(x)/x”,-1000,2000);
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
TF1 f1("f1", "(abs(x) > 1.e-11 ? sin(x) / x : 1.)", 0., 2000.);
Hi @Subhu18 ,
sin(x)/x is not defined at
x==0, but it tends to 1 in the limit in which x tends to 0.
In order to draw the plot, TF1 simply evaluates the function in a few points and then interpolates. With the larger range, the sampling is too coarse and close to
x==0 you get a datapoint that corresponds e.g. to
x == 1.5 or something like that.
in other words it’s just an artifact of the visualization done via sampling. If you evaluate the
x==0 you get the correct behavior, e.g.:
root  auto *f = new TF1("f1", "sin(x)/x", -2000, 2000)
(TF1 *) 0x562d34d5ee50
root  f->Eval(0.1)
root  f->Eval(0.001)
May I know the reason the whats wrong with my code??
thank you for the clarification sir.