# -*- coding: utf-8 -*- """ logistic_iterator.py finds values of the logistic map, f[i](x) = ax(1-x), for repeated iterations as i becomes large, approximates period doubling points, and finds said period points for a between 2.9 and values close to 4.0 I'm trying to do something like this: en.wikipedia.org/wiki/File:LogisticMap_BifurcationDiagram.png Created on Sun Oct 6 12:48:35 2013 @author: coriander """ from scipy import arange def logistic(a, x): value = a*x*(1-x) return value def iterated_logistic(a_val, x_n, out_len=1, n=1000): ''' Iterates the logistic map Returns a list of varying length with the last iterates of f(x) ''' out_list = [0]*out_len for i in xrange(0, n): x_n = logistic(a_val, x_n) xn1 = logistic(a_val, x_n) if xn1 != x_n: # return a list of twice the previous size else: # return current sized list return out_list def logi_loop(a_0=2.95, x_0=0.25): array_list = [] for a in arange(a_0, 3.98, 0.01): #start, (up to) end, step (rationals), x_array = iterated_logistic(a, x_0, out_len=out_length) #lists of lists, oh my! array_list.append(x_list) #the list of the lists of x values for large n # change to print list: print "For a = {:.3f}: x_n = {:.4f}".format(a, x_i) #return x_n def main(): logi_loop() pass main()