nixpulvis

# Euler’s Identity

This equation is supremely beautiful and bewildering. It uses 5 very fundamental objects: $0$, $1$, $\pi = 3.141\ldots$, $e = 2.718\ldots$, and $i = \sqrt{-1}$, along with 4 operations: $a + b$ (addition), $a b$ (multiplication), $a^b$ (exponentiation), and finally $a = b$ (equality, identity).

Then it repeats…

If you can’t see the “whole” picture yet (can anyone?), this might help. Our cyclic circular sidekicks, $\sin$ and $\cos$ are here to enlighten us.

Euler’s identity is a special case of Euler’s formula, which states:

Substitute $\pi$ (or in general, $n\pi$) for $\theta$ and we get back our identity.

Tangent on Fourier Series
Plot[
sin(theta)/pi,
(3/2) sin(theta)/pi,
2     sin(theta)/pi,
(5/2) sin(theta)/pi
]


Unlike the Euler series we above, which is purely constructive, a square wave can be constructed with the Fourier series:

Plot[
sin(2 pi theta),
(1/3) sin(6 pi theta),
(1/5) sin(10 pi theta)
]


And a saw wave can be constructed by another:

Plot[
sin(pi theta),
sin((pi theta) / 2),
sin((pi theta) / 4)
]


Euler’s identity can be geometrically interpreted as saying that rotating any point $\pi$ radians around an origin of a complex plane has the same effect as reflecting the point across the origin.

Fundamentally, Euler’s Identity is a root of unity, meaning that it is a solution for $z$ in the equation $z^n = 1$.

This is the definition for a more general identity which states that the $n$th roots of unity, for $n \gt 1$, add up to $0$.

Euler’s identity is the $n = 2$ case of this equation.

Wanna compute e in Brainfuck? $$\hphantom{nothing} \\ e = 2.718281828459\ldots$$

git clone https://github.com/nixpulvis/brainfuck
cd brainfuck
cargo run fixtures/e.bf


>>>>++>+>++>+>>++<+[
[>[>>[>>>>]<<<<[[>>>>+<<<<-]<<<<]>>>>>>]+<]>-
>>--[+[+++<<<<--]++>>>>--]+[>>>>]<<<<[<<+<+<]<<[
>>>>>>[[<<<<+>>>>-]>>>>]<<<<<<<<[<<<<]
>>-[<<+>>-]+<<[->>>>[-[+>>>>-]-<<-[>>>>-]++>>+[-<<<<+]+>>>>]<<<<[<<<<]]
>[-[<+>-]]+<[->>>>[-[+>>>>-]-<<<-[>>>>-]++>>>+[-<<<<+]+>>>>]<<<<[<<<<]]<<
]>>>+[>>>>]-[+<<<<--]++[<<<<]>>>+[
>-[
>>[--[++>>+>>--]-<[-[-[+++<<<<-]+>>>>-]]++>+[-<<<<+]++>>+>>]
<<[>[<-<<<]+<]>->>>
]+>[>>>>]-[+<<<<--]++<[
[>>>>]<<<<[
-[->--[<->+]++<[[>-<+]++[<<<<]+>>+>>-]++<<<<-]
>-[+[<+[<<<<]>]<+>]+<[->->>>[-]]+<<<<
]
]>[<<<<]>[
-[
-[
+++++[>++++++++<-]>-.>>>-[<<<----.<]<[<<]>>[-]>->>+[
[>>>>]+[-[->>>>+>>>>>>>>-[-[+++<<<<[-]]+>>>>-]++[<<<<]]+<<<<]>>>
]+<+<<
]>[
-[
->[--[++>>>>--]->[-[-[+++<<<<-]+>>>>-]]++<+[-<<<<+]++>>>>]
<<<<[>[<<<<]+<]>->>
]<
]>>>>[--[++>>>>--]-<--[+++>>>>--]+>+[-<<<<+]++>>>>]<<<<<[<<<<]<
]>[>+<<++<]<
]>[+>[--[++>>>>--]->--[+++>>>>--]+<+[-<<<<+]++>>>>]<<<[<<<<]]>>
]>
]

This program computes the transcendental number e, in decimal. Because this is
infinitely long, this program doesn't terminate on its own; you will have to
kill it. The fact that it doesn't output any linefeeds may also give certain
implementations trouble, including some of mine.

(c) 2016 Daniel B. Cristofani
http://brainfuck.org/