numexpr
numexpr copied to clipboard
Improve accuracy of expm1 for complex arguments
Fixes #418.
The imaginary part of the result differs slightly from the numpy result (hence the nulp=2500
) in the test. Strangely, this difference disappears if the exponential of the real part is assigned to a temporary value (i.e., as it is currently computed):
static void
nc_expm1(npy_cdouble *x, npy_cdouble *r)
{
double a = sin(x->imag / 2);
double b = exp(x->real);
r->real = expm1(x->real) * cos(x->imag) - 2 * a * a;
r->imag = b * sin(x->imag);
return;
}
Any idea why @robbmcleod?
Closing as I implemented myself, thanks for the contribution though!