Skip to content

Instantly share code, notes, and snippets.

@dmishin
Last active November 22, 2018 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmishin/5baff0f2aa1ce90213162c10aedb10a1 to your computer and use it in GitHub Desktop.
Save dmishin/5baff0f2aa1ce90213162c10aedb10a1 to your computer and use it in GitHub Desktop.
Numerically calculate fractional iterate of x^2-2
def approxfi(x, n):
#Apply x -> F(x) mapping until x is sufficiently large
k = 0
while (x < 1e14) and (k<100):
x = x**2-2
k += 1
#Calculate approximate fractional iterate for large argument
x = x**(2**n)
#Apply reverse mapping x -> F[-1](x)
for _ in range(k):
x = (x+2)**0.5
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment