python-3.xsympy

Why doesn't SymPy evaluate i^i?


I tried to evaluate the following in Python 3.8.2 using SymPy 1.5.1.

from sympy import *
a = I**I
print(a)

This returns:

I**I

Googling I**I and it gives exp(-pi/2) which is 0.2079. Does SymPy simply not know how to compute this? Or is there something I am missing?


Solution

  • You can rewrite in exponential form if you want:

    In [12]: I**I                                                                                                                     
    Out[12]: 
     ⅈ
    ⅈ 
    
    In [13]: (I**I).rewrite(exp)                                                                                                      
    Out[13]: 
     -π 
     ───
      2 
    ℯ 
    

    You can also evaluate the result in floating point:

    In [14]: (I**I).n()                                                                                                               
    Out[14]: 0.207879576350762