Skip to content

Commit 2530847

Browse files
committed
MAINT: Use trig identity to evaluate cosm1.
1 parent 5d9cab9 commit 2530847

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

numpy/core/src/umath/funcs.inc.src

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,8 @@ nc_exp2@c@(@ctype@ *x, @ctype@ *r)
360360
static void
361361
nc_expm1@c@(@ctype@ *x, @ctype@ *r)
362362
{
363-
@ftype@ a = npy_cos@c@(x->imag);
364-
r->real = npy_expm1@c@(x->real) * a + (a - 1);
363+
@ftype@ a = npy_sin@c@(x->imag / 2);
364+
r->real = npy_expm1@c@(x->real) * npy_cos@c@(x->imag) - 2 * a * a;
365365
r->imag = npy_exp@c@(x->real) * npy_sin@c@(x->imag);
366366
return;
367367
}

0 commit comments

Comments
 (0)