Code to calculate tetration using my method
#1
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
Reply


Messages In This Thread
Code to calculate tetration using my method - by Shanghai46 - 06/02/2023, 08:33 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Terse Schroeder & Abel function code Daniel 1 3,101 10/16/2022, 07:03 AM
Last Post: Daniel
  The beta method program JmsNxn 0 3,499 02/25/2022, 03:05 AM
Last Post: JmsNxn
  C++ code for tet, ate and hexp MorgothV8 0 7,203 07/10/2014, 04:24 PM
Last Post: MorgothV8
  Which method is currently "the best"? MorgothV8 2 11,979 11/15/2013, 03:42 PM
Last Post: MorgothV8
  "Kneser"/Riemann mapping method code for *complex* bases mike3 2 15,443 08/15/2011, 03:14 PM
Last Post: Gottfried
  An incremental method to compute (Abel) matrix inverses bo198214 3 18,975 07/20/2010, 12:13 PM
Last Post: Gottfried
  Single-exp series computation code mike3 0 6,680 04/20/2010, 08:59 PM
Last Post: mike3
  Toying with the Borel summation to calculate tetration mike3 11 40,861 03/25/2010, 09:00 PM
Last Post: mike3
  SAGE code for computing flow matrix for exp(z)-1 jaydfox 4 20,467 08/21/2009, 05:32 PM
Last Post: jaydfox
  Matrix-method: compare use of different fixpoints Gottfried 23 64,793 11/30/2007, 05:24 PM
Last Post: andydude



Users browsing this thread: 1 Guest(s)