Skip to content

Instantly share code, notes, and snippets.

View gvitalie's full-sized avatar
🌻

Vitalie Ghelbert gvitalie

🌻
View GitHub Profile
@gvitalie
gvitalie / ❄.py
Last active November 24, 2025 06:37
e^(jx) calculate exact π value.
me@amadeus:~$ python3 -q
>>> def exp(x):
... prod = a = 1
... for i in range(1, 30):
... prod *= x/i
... a += prod
... return a
...
>>> x = 1.5
>>> for i in range(3):
@gvitalie
gvitalie / π.py
Created November 23, 2025 13:49
π using e^x
me@amadeus:~$ python3 -q
>>> import math
>>>
>>> def exp(x):
... a = 1
... for i in range(1, 30):
... a += (x ** i) / math.factorial(i)
... return a
...
>>> x = 3
@gvitalie
gvitalie / π.py
Created November 23, 2025 07:09
Fun
me@amadeus:~$ python3 -q
>>> import math
>>>
>>> def exp(x):
... a = 1
... for i in range(1, 100):
... a += (x ** i) / math.factorial(i)
... return a
...
>>> def ln(x):
@gvitalie
gvitalie / ❄.py
Last active September 19, 2025 09:07
Euler and Newton relations make a tandem 🚲 to calculate π value, using successive exponential tangent.
me@amadeus:~$ python3 -q
>>>
>>> import cmath
>>>
>>> a = 3
>>> for i in range(3):
... a -= cmath.exp(a * 1j).imag/cmath.exp(a * 1j).real
...
>>>
>>> print(a)
@gvitalie
gvitalie / e^x.py
Created September 17, 2025 15:33
e^x
me@amadeus:~$ python3 -q
>>>
>>> import cmath
>>>
>>> a = 3
>>> for i in range(3):
... a += cmath.exp(a * 1j).imag
...
>>> print(a)
3.141592653589793
@gvitalie
gvitalie / 😇.py
Created September 13, 2025 14:43
😇
import math
def sin(x):
a = 0
for i in range(30):
a += ((-1) ** i) * (x ** (2*i+1)) / math.factorial(2*i+1)
return a
a = 3
for i in range(3):
@gvitalie
gvitalie / π.py
Created September 13, 2025 09:06
π
me@amadeus:~$ python3 -q
>>>
>>> from math import sin
>>>
>>> a = 3
>>> for i in range(3):
... a += sin(a)
...
>>> print(a)
3.141592653589793