This affects also acoth(), asec() and acsc(). In short, everything, that's using 1/z for inversion. E.g., the acot() implemented as:
def acot(ctx, z):
if not z:
return ctx.pi * 0.5
else:
return ctx.atan(ctx.one / z)
But:
>>> mp.one/mp.mpc(cmath.infj)
mpc(real='0.0', imag='nan')
>>> fp.one/fp.mpc(cmath.infj)
-0j
On another hand, we have:
>>> mp.mpc(cmath.infj)**-1
mpc(real='0.0', imag='0.0')
>>> fp.mpc(cmath.infj)**-1
(nan+nanj)
Of course, it's yet another instance of this issue. With special rules for mixed arithmetic (e.g. real+complex as in this case), we should have -0j (or just 0 for the mp context, without signed zero).
As a workaround, we could add a branch for infinite z.
This affects also
acoth(),asec()andacsc(). In short, everything, that's using1/zfor inversion. E.g., theacot()implemented as:But:
On another hand, we have:
Of course, it's yet another instance of this issue. With special rules for mixed arithmetic (e.g. real+complex as in this case), we should have
-0j(or just0for the mp context, without signed zero).As a workaround, we could add a branch for infinite
z.