e i π + 1 = 0However, in Python, this isn’t quite true:
If you note, the imaginary component is quite small: -1 x 10-16.
>>> import math
>>> math.e**(math.pi*1j) + 1
Python is Steve’s tool of choice, so it’s possible to misread his post and believe that python got the answer wrong. However, the error is fundamental. Witness:
As I said, it would be possible to misread Steve’s post as a complaint against Python. It is not. As he says:
Prelude> :m + Data.Complex
Prelude Data.Complex> let e = exp 1 :+ 0
Prelude Data.Complex> let ipi = 0 :+ pi
Prelude Data.Complex> e
2.718281828459045 :+ 0.0
Prelude Data.Complex> ipi
0.0 :+ 3.141592653589793
Prelude Data.Complex> e ** ipi + 1
0.0 :+ 1.2246063538223773e-16
I believe the results would be just as disappointing in any other languageAnd indeed they are, thanks to irrational numbers like π and the limitations of IEEE doubles.
Updated: corrected uses of -iπ with the proper exponent, iπ.