06/02/2023, 08:33 AM
This is the python code I've made to easily calculate tetration using my method. It calculates x^^(a+bi) for all a, b real (except a whole and below -2) and for all x greater that e^-e. It might not be 100% precise, and maybe some mistakes, but it overall works.
To calculate, it's tetra(x,a,b) for x^^(a+bi)
from math import*
def mod(a,b):
A=(a**2+b**2)**0.5
return A
def Arg(a,b):
Z=atan2(b,a)
return Z
def fn(a,n):
X=0
while n+1>0:
n=n-1
X=a**X
return X
def logan(X,Y,a,n):
while n>0:
M=mod(X,Y)
A=Arg(X,Y)
X=log(M,a)
Y=(A)/log(a,e)
n=n-1
return X,Y
def TAU(X):
n=0
a=1
while n<400:
a=X**a
n=n+1
return a
def LAMBDA(X):
a=log(X,e)*TAU(X)
return a
def lpr(x,p,b):
X=LAMBDA(x)
if X>=0:
A=(X**p)*cos(log(X,e)*b)
else:
A=e**(log(-X,e)*p-pi*b)*cos(log(-X,e)*b+p*pi)
return A
def lpi(x,p,b):
X=LAMBDA(x)
if X>=0:
A=(X**p)*sin(log(X,e)*b)
else:
A=e**(log(-X,e)*p-pi*b)*sin(log(-X,e)*b+p*pi)
return A
def entier(X):
X=floor(X)
return X
def decimal(X):
a=entier(X)
b=X-a
return b
def Nu(X):
n=0
a=fn(X,n)
b=TAU(X)
while ((a-b)**2)**0.5>0.0001:
n=n+1
a=fn(X,n)
return n
def tetraa(X,a,b):
E=entier(a)
D=decimal(a)
N=Nu(X)
A=fn(X, N+E)-TAU(X)
B=(A*(lpr(X, D,b)))+TAU(X)
C=(A*(lpi(X, D,b)))
O=logan(B,C,X,N)
return O
def BIGn(X):
n=X
a=1
if 3.9<X<5:
X=X**X
a=2
else:
while X-3000<0:
X=n**X
a=a+1
return a
def BIGx(X):
n=X
if 3.9<X<5:
X=X**X
else:
while X-3000<0:
X=n**X
return X
def logwan(X,a,n):
while n>0:
X=log(X+1,a)
n=n-1
return X
def PUr(X,a,b,n):
while n>0:
A=(X**a)*cos(log(X,e)*b)
B=(X**a)*sin(log(X,e)*b)
a=A
b=B
n=n-1
return a
def PUi(X,a,b,n):
while n>0:
A=(X**a)*cos(log(X,e)*b)
B=(X**a)*sin(log(X,e)*b)
a=A
b=B
n=n-1
return b
def Gn(a,b,X,n):
while n>0:
A=(X**a)*cos(log(X,e)*b)-1
B=(X**a)*sin(log(X,e)*b)
a=A
b=B
n=n-1
return a,b
def lim(X):
A=BIGx(X)
if X<e:
b=logwan(A,X,400)
else:
b=0
return b
def gamma(X):
A=(lim(X)+1)*log(X,e)
return A
def NA(X):
A=BIGx(X)
B=lim(X)
n=0
while ((A-B)**2)**0.5>10**(-6):
n=n+1
A=logwan(A,X,1)
return n
def fin(X,p,b):
E=decimal(1-decimal(p))
Z=entier(p)
A=BIGx(X)
B=logwan(A,X,NA(X))
C=B-lim(X)
D=(C/(gamma(X)**E)*cos(log(gamma(X),e)*b))+lim(X)
W=(C/(gamma(X)**E)*sin(log(gamma(X),e)*b))
F,U=Gn(D,W,X,NA(X))
Y=BIGn(X)-E-p
if Y>=0:
O=logan(F,U,X,Y)
else:
O=PUr(F,U,X,-Y),PUi(F,U,X,-Y)
return O
def tetra(X,n,b):
if X==1:
Z=(1,0)
elif n<=-2 and n==int(n) and b==0:
Z="ERROR"
elif n>=-1 and decimal(n)<=0 and b==0:
Z=fn(X,n)
else:
if e**(-e)<=X<=e**(1/e):
Z=tetraa(X,n,b)
elif X>e**(1/e):
Z=fin(X,n,b)
else:
Z="ERROR"
return Z
To calculate, it's tetra(x,a,b) for x^^(a+bi)
from math import*
def mod(a,b):
A=(a**2+b**2)**0.5
return A
def Arg(a,b):
Z=atan2(b,a)
return Z
def fn(a,n):
X=0
while n+1>0:
n=n-1
X=a**X
return X
def logan(X,Y,a,n):
while n>0:
M=mod(X,Y)
A=Arg(X,Y)
X=log(M,a)
Y=(A)/log(a,e)
n=n-1
return X,Y
def TAU(X):
n=0
a=1
while n<400:
a=X**a
n=n+1
return a
def LAMBDA(X):
a=log(X,e)*TAU(X)
return a
def lpr(x,p,b):
X=LAMBDA(x)
if X>=0:
A=(X**p)*cos(log(X,e)*b)
else:
A=e**(log(-X,e)*p-pi*b)*cos(log(-X,e)*b+p*pi)
return A
def lpi(x,p,b):
X=LAMBDA(x)
if X>=0:
A=(X**p)*sin(log(X,e)*b)
else:
A=e**(log(-X,e)*p-pi*b)*sin(log(-X,e)*b+p*pi)
return A
def entier(X):
X=floor(X)
return X
def decimal(X):
a=entier(X)
b=X-a
return b
def Nu(X):
n=0
a=fn(X,n)
b=TAU(X)
while ((a-b)**2)**0.5>0.0001:
n=n+1
a=fn(X,n)
return n
def tetraa(X,a,b):
E=entier(a)
D=decimal(a)
N=Nu(X)
A=fn(X, N+E)-TAU(X)
B=(A*(lpr(X, D,b)))+TAU(X)
C=(A*(lpi(X, D,b)))
O=logan(B,C,X,N)
return O
def BIGn(X):
n=X
a=1
if 3.9<X<5:
X=X**X
a=2
else:
while X-3000<0:
X=n**X
a=a+1
return a
def BIGx(X):
n=X
if 3.9<X<5:
X=X**X
else:
while X-3000<0:
X=n**X
return X
def logwan(X,a,n):
while n>0:
X=log(X+1,a)
n=n-1
return X
def PUr(X,a,b,n):
while n>0:
A=(X**a)*cos(log(X,e)*b)
B=(X**a)*sin(log(X,e)*b)
a=A
b=B
n=n-1
return a
def PUi(X,a,b,n):
while n>0:
A=(X**a)*cos(log(X,e)*b)
B=(X**a)*sin(log(X,e)*b)
a=A
b=B
n=n-1
return b
def Gn(a,b,X,n):
while n>0:
A=(X**a)*cos(log(X,e)*b)-1
B=(X**a)*sin(log(X,e)*b)
a=A
b=B
n=n-1
return a,b
def lim(X):
A=BIGx(X)
if X<e:
b=logwan(A,X,400)
else:
b=0
return b
def gamma(X):
A=(lim(X)+1)*log(X,e)
return A
def NA(X):
A=BIGx(X)
B=lim(X)
n=0
while ((A-B)**2)**0.5>10**(-6):
n=n+1
A=logwan(A,X,1)
return n
def fin(X,p,b):
E=decimal(1-decimal(p))
Z=entier(p)
A=BIGx(X)
B=logwan(A,X,NA(X))
C=B-lim(X)
D=(C/(gamma(X)**E)*cos(log(gamma(X),e)*b))+lim(X)
W=(C/(gamma(X)**E)*sin(log(gamma(X),e)*b))
F,U=Gn(D,W,X,NA(X))
Y=BIGn(X)-E-p
if Y>=0:
O=logan(F,U,X,Y)
else:
O=PUr(F,U,X,-Y),PUi(F,U,X,-Y)
return O
def tetra(X,n,b):
if X==1:
Z=(1,0)
elif n<=-2 and n==int(n) and b==0:
Z="ERROR"
elif n>=-1 and decimal(n)<=0 and b==0:
Z=fn(X,n)
else:
if e**(-e)<=X<=e**(1/e):
Z=tetraa(X,n,b)
elif X>e**(1/e):
Z=fin(X,n,b)
else:
Z="ERROR"
return Z