Re: [ROOT] tiny Bug in root

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sat Dec 01 2001 - 08:14:49 MET


Hi Valery,

I am sorry, but the solution proposed by Kurt is correct.
Concerning the precision problem in tests like x==0, you can
always replace them in the expression by x<epsilon.

TF1 has already some logic (when drawing) to "discover" an asymptotic
behaviour in cases where a division by 0 is found. This logic could be
extended to TFormula::Eval and TF1::Eval. When a division by 0 is found,
an additional pass could be done automatically to evaluate the derivatives
around the point x and estimate the point with a linear or parabolic
interpolation. I was planning to implement this algorithm. However,
if somebody has a better idea, let me know.
Obviously this makes sense only for interpreted functions (TFormula).

Rene Brun

On Fri, 30 Nov 2001, Valeri Fine wrote:

> 
> 
> 
> > Hi,
> > 
> > there is a way to obtain the desired behaviour by defining the function
> > in the proper way:
> > 
> > root [0] TF1* f1 = new TF1("f1","(sin(x)/x)*(x>0.0)+ 1.0*(x==0.0)",0,10)
> 
> I am not sure this trick helps much  because the quantity of the "floating point"
> numbers is limited rather infinite as the pure math claims for "real" numbers 
> (see some numerical calculation book or "Fortran language manual"  for further explanation) 
> and the number of points between any two floating-points is finite too.
> The books explain why one can not rely on the floating-point  expression like "x == 0.0" either.
> As result the expression above is not better then the oriogibnal one but more complex to understand
> At least the same result one can get with 
> 
> Float_t epsilon = 0.0001;   // How to choose that epsilon many books explain.
> TF1* f1 = new TF1("f1","(sin(x)/x),epsilon,10)
> 
>    Hope this helps, 
> 
>                             Best regardes, Valeri
> 
> > root [1] f->Eval(0)
> > (Double_t)1.00000000000000000e+00
> > root [3] f->Eval(1.0)
> > (Double_t)8.41470984807896505e-01
> > 
> > I'm not sure whether you run into problems when doing a fit with this, though.
> > 
> > best,
> > Kurt
> >  
> > > > Dear ROOTERs,
> > > > 
> > > > I have a test on the following code:
> > > > 
> > > > TF1 f1("func1", "sin(x)/x", 0, 10)
> > > > f1.Eval(0),
> > > > 
> > > > 
> > > > It gives the value 0 instead of 1.
> > 
> > -- 
> > Kurt Rinnert, University of Karlsruhe (TH) - Faculty for Physics
> > 
> 



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:10 MET