user
|  |
| --- |
| This page uses content from **Wikipedia**. The original article was at Euler's\_identity. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) |

In mathematics, *Euler's identity* is the equality:

```
               ei
  
    
      
        
          
            π
          
        
      
    
    {\displaystyle {\displaystyle \pi }}
  
 + 1 = 0

```

where

```
   e is Euler's number, the base of natural logarithms,
   i is the imaginary unit, which satisfies i2 = −1, and
   
  
    
      
        
          
            π
          
        
      
    
    {\displaystyle {\displaystyle \pi }}
  
 is pi, the ratio of the circumference of a circle to its diameter.

```

Euler's identity is often cited as an example of deep mathematical beauty. Three of the basic arithmetic operations occur exactly once each: addition, multiplication, and exponentiation. The identity also links five fundamental mathematical constants:

```
   The number 0.
   The number 1.
   The number 
  
    
      
        
          
            π
          
        
      
    
    {\displaystyle {\displaystyle \pi }}
  
 (
  
    
      
        
          
            π
          
        
      
    
    {\displaystyle {\displaystyle \pi }}
  
 = 3.14159+),
   The number e (e = 2.71828+), which occurs widely in mathematical analysis.
   The number i, the imaginary unit of the complex numbers.

```

Task

Show in your language that Euler's identity is true. As much as possible and practical, mimic the Euler's identity equation.

Most languages are limited to IEEE 754 floating point calculations so will have some error in the calculation.

If that is the case, or there is some other limitation, show
that ei

π
{\displaystyle {\displaystyle \pi }} + 1 is *approximately* equal to zero and
show the amount of error in the calculation.

If your language is capable of symbolic calculations, show
that ei

π
{\displaystyle {\displaystyle \pi }} + 1 is *exactly* equal to zero for bonus kudos points.
assistant
(formerly Perl 6)

**Works with**: Rakudo version 2018.03

Implementing an "invisible times" operator (Unicode character (U+2062)) to more closely emulate the layout. Alas, Raku does not do symbolic calculations at this time and is limited to IEEE 754 floating point for transcendental and irrational number calculations.

e, i and π are all available as built-in constants in Raku.

```
sub infix:<⁢> is tighter(&infix:<**>) { $^a * $^b };

say 'e**i⁢π + 1 ≅ 0 : ', e**i⁢π + 1 ≅ 0;
say 'Error: ', e**i⁢π + 1;

```

Output:

```
e**i⁢π + 1 ≅ 0 : True
Error: 0+1.2246467991473532e-16i
```