From pfortini at wyeth.com  Thu Apr  7 23:41:08 2005
From: pfortini at wyeth.com (pfortini@wyeth.com)
Date: Thu Apr  7 23:41:15 2005
Subject: [Rd] complex tangent (PR#7781)
Message-ID: <20050407214108.A4A5FCA4D@slim.kubism.ku.dk>

Full_Name: Peter Fortini
Version: 2.0.1
OS: Windows 2000
Submission from: (NULL) (65.246.187.164)


When the imaginary part of the argument is very large, the complex tangent
function returns 0+NaNi.  For example, tan(1+1000i)=0+NaNi; it should be 0+1i

Easy to fix in complex.c, as the original NaN came from division of sinh and
cosh that had reached machine infinity. 

static void z_tan(Rcomplex *r, Rcomplex *z)
{
    double x2, y2, den;
    x2 = 2.0 * z->r;
    y2 = 2.0 * z->i;
    den = cos(x2) + cosh(y2);
    r->r = sin(x2)/den;
    /* any limit above about log(DBL_EPSILON) will do */
    if (fabs(r->i) < 40.0) 
      r->i = sinh(y2)/den;
    else
      r->i = 1.0;
}


[Rd] complex tangent (PR#7781)
pfortini@wyeth.com