Hacker News new | past | comments | ask | show | jobs | submit login

it isn't necessary in Python, either. GP is only importing it for square roots, but exponentiation (via the ** operator) by .5 works fine with complex numbers in Python as well. It even handles complex exponents (although you'd have to look up the branch cut semantics etc. in the documentation):

    >>> (1+1j)**(1+1j)
    (0.2739572538301211+0.5837007587586147j)
Ironically, the `math` library doesn't handle that:

    >>> math.pow(1+1j, 1+1j)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: must be real number, not complex



Definitely. I was mainly trying to avoid using `**` as non-Python users might be more familiar with '^' instead.


Works in Julia:

  julia> (1+im)^(1+im)
  0.2739572538301211 + 0.5837007587586147im




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: