After watching 3Blue1Brown's Power Tower puzzle, I tried to apply the same process to quadratics and found some quiet nice looking results although I'm not really sure what's going on here. I mostly focused on the function $f(x)= x^2 -3x + c$. Coding it in Python showed that at certain values the iterative process would become cyclic 7-cycle for a c value of 2.1752842932
import decimal
import matplotlib.pyplot as plt
from decimal import *
import random
getcontext().prec = 100
y = 3.1 # Start Value 1.7,3.25,3.05,2.82
Max = 100000 # max value of iterations
c = 2.1752842932
# possible seed values for c [value of c(expected cycle)]
# 2(3) 1.80944920946(4) 2.125603004(5) 2.1752842932(7) 2.15435070118 (9)
# 2.30322273136(10) 2.202099797836(11) 2.3332893054 (12) 2.204798684441(13) 2.313623776338 (14)
liste = []
liste2 = []
def calc():
global y
print(y)
y = decimal.Decimal(y * y) - Decimal(3) * decimal.Decimal(y) + Decimal(c)
for i in range(Max):
if i < 1:
calc()
liste.append(y)
elif 1 <= i < Max - 1:
calc()
liste.append(y)
liste2.append(y)
else:
calc()
liste2.append(y)
print(len(liste))
print(len(liste2))
st = random.randint(1, 10000)
indexstring = "1plot" + str(st) + ".svg"
plt.plot(liste, liste2, '-o', linewidth=0.1, markersize=0.1)
plt.savefig(indexstring)
plt.show()
Graphing it in Desmos showed that those cycles emerge when the function $f(f(f(x))$ has exactly three touching points and two crossing points with the function $y=x$.
Although I have no Idea if that is the case for every function. 7-cycel with 7 touching points and 2 crossing points. That way I could approximate the values of an n cycle by creating the function $f(f(\ldots f(x))$ and ever so slightly correct the $c$ value until it didn't cross the $y=x$ axis anymore.
Graphing the speed of convergence given a starting value to iterate on, to a certain cyclic value also gives some nice results.speed of convergence with $c=e$ $x=$Seed value for iteration $y=$iteration to convergence. Speed of convergence with $c = 2$. To find a starting value that becomes cyclic or converges it needs to be an x-value within the two blue lines on the graph below.boundaries for convergence
import decimal
import matplotlib.pyplot as plt
from decimal import *
import random
getcontext().prec = 100 # accuracy of calculation in digits
y = 0
Startval_Rangefinder = 2.5
increment = 0.01 # increment stepping down from ymax to ymin startingvalue
ymax = 4 # give the range of startvalues for the iteration
ymin = -1
Max = 100000 # max value of iterations
c = 3.5
# possible seed values for c [value of c(expected cycle)]
# 2(3) 1.80944920946(4) 2.125603004(5) 2.1752842932(7) 2.15435070118 (9)
# 2.30322273136(10) 2.202099797836(11) 2.3332893054 (12) 2.204798684441(13) 2.313623776338 (14)
startval = ymax
listx = []
listy = []
def calc():
global y
print(y)
y = decimal.Decimal(y * y) - Decimal(3) * decimal.Decimal(y) + Decimal(c)
def rangefinder(): # finds one of the number the process converges to
global y
y = Startval_Rangefinder
for r in range(Max):
calc()
if r >= Max - 1:
return y
k = rangefinder()
konv = float(k)
upper_bound = konv + 0.00001
lower_bound = konv - 0.00001
while decimal.Decimal(startval) >= decimal.Decimal(ymin):
y = startval
for i in range(Max):
if y > 10:
listy.append(-10)
listx.append(startval)
break
elif lower_bound <= y <= upper_bound:
listy.append(i)
listx.append(startval)
break
elif i >= Max and lower_bound >= y >= upper_bound:
listy.append(-10)
listx.append(startval)
break
calc()
startval = decimal.Decimal(startval) - decimal.Decimal(increment)
print(len(listy))
print(len(listx))
st = random.randint(1, 10000)
indexstring = "2plot" + str(st) + ".svg"
plt.plot(listx, listy, '-o', linewidth=1, markersize=1)
plt.savefig(indexstring)
plt.show()
To be quite honest with you I have no Idea what's going on here maybe something Feigenbaumy? The code I wrote is quite bad, but it works, kinda of. Feel free to play around with it