Bug in tanh?



>>>>> "Barton" == Barton Willis <willisb at unk.edu> writes:

    Barton> -----maxima-bounces at math.utexas.edu wrote: -----
    >> I suspect it is sufficient to compute
    >> Tanh = 2/(exp(-2*x)+1)  -1

I think this doesn't work so well for small x.  

    Barton> In trigi.lisp cvs r 1.9, we had

    Barton> I was largely responsible for the move toward turning over
    Barton> most double float evaluation for trig-like functions to CL
    Barton> (we all did debate the change on the list).  If there is a
    Barton> well-tested CL library for floating point evaluation of
    Barton> trig-like functions, changing back to our own code
    Barton> wouldn't be difficult.

I'm not aware of any such CL library. However, maxima already has a
bigfloat implementation of complex tanh.  This could be modified
slightly to handle the real-valued case.  I believe this version is
quite accurate for small x as well as for large x.  This
implementation is based on Kahan's complex version.

Ray