[BUG] Complex vjps are wrong for arcsin/arccos/arctan/arcsinh/arccosh/arctanh (missing conjugate)
Author: obchainCreated Jun 29, 2026Updated Sep 26, 2026
Labelsbuglow priority
Describe the bug
The inverse trigonometric / hyperbolic ops return the wrong gradient for complex inputs: their vjp delegates to their jvp, so the conjugate is dropped. For a holomorphic f the vjp must be cotangent * conj(f'(z)).
Affected: arccos, arccosh, arcsin, arcsinh, arctan, arctanh.
This is the same issue fixed for square/sin/tanh/… in #3766.
To Reproduce
import mlx.core as mx
z = mx.array(0.3 + 0.2j, mx.complex64)
g = mx.array(1.0 + 1.0j, mx.complex64)
vjp = mx.vjp(mx.arctan, [z], [g])[1][0]
expected = g * mx.conj(1 / (1 + z**2)) # cotangent * conj(f'(z))
print(vjp, expected) # differExpected behavior
vjp == cotangent * conj(f'(z)), consistent with mx.exp/mx.log and finite differences.
Desktop
- OS: macOS
- Version: main (0.32.0.dev)
Source: ml-explore/mlx