How can I calculate Feigenbaum's constant?

So I am trying to calculate Feigenbaum's constant for the logistic map: $$x_{n+1} = 4 \lambda x_n (1-x_n)$$ I am writing this through python and the main pieces I have for my code that are relevant are:

def logistic(L,x):
return 4*L*x*(1-x)
n = 1000
iterations = 1000
keep = 500
L = np.linspace(0.4,1.0,n)
x = 1e-4 * np.ones(n)
for i in range(iterations):
x = logistic(L,x)

if i >= (iterations - keep):
plt.plot(L,x,'.k', markersize=0.1)

I currently only have the packages numpy and matplotlib imported in my code.

So this gives me a nice bifurcation diagram but I was curious about how I would be able to calculate Feigenbaum's constant from this? I know I can go through it region by region and manually calculate the sections where I get period doubling but I would like to be able to do something more robust. I did read on Wikipedia that Feigenbaum's constant can be calculated from: $$\frac{\lambda_{n-1} - \lambda_{n-2}}{\lambda_{n-1} - \lambda_{n}}$$ for the sections of period doubling. But again from the current code I have in place, I can only think of doing this through manual calculation. Any suggestions would be greatly appreciated.

• I am not sure whether there is a shortcut. I think, Wikipedia only mentions the Feigenbaum constants, I did not see a method to find them. Mar 17 '19 at 15:08