1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Why do imaginary number calculations behave differently for exponents up to 100 and...

Discussão em 'Python' iniciado por Stack, Setembro 16, 2024.

  1. Stack

    Stack Membro Participativo

    The imaginary number i, or j in Python, means the square root of -1. So, i to the 4th or any multiple of 4 should be positive 1.

    >>> (1j)**4
    (1+0j)
    >>> (1j)**96
    (1+0j)
    >>> (1j)**100
    (1+0j)


    Up until this point all is good, but once we get past 100, Python just bugs out. For example:

    >>> (1j)**104
    (1+7.842691359635767e-15j)


    This messed up my calculations so much in an unexpected way. What explains this? I'm using Python 3.8.19.

    Continue reading...

Compartilhe esta Página