Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News Sign UpSign In
| Download

orbit presentation

Project: Math 2030
Views: 24
fcn(x) = piecewise([((-1,.5),2*x), ([.5,1],2*x-1)]) DisplayOrbit = [] skip = 90; maxit = 100 ; x0 = (1/3) nextx = var('nextx') oldx = x0 FullOrbit = [oldx] for i in range(0,maxit): nextx = fcn(oldx) FullOrbit.append(nextx) oldx = nextx DisplayOrbit = FullOrbit[skip:maxit] print table(columns = [range(skip,maxit),DisplayOrbit],header_row=['iter','orbit'],frame=true)
+------+-------+ | iter | orbit | +======+=======+ | 90 | 1/3 | +------+-------+ | 91 | 2/3 | +------+-------+ | 92 | 1/3 | +------+-------+ | 93 | 2/3 | +------+-------+ | 94 | 1/3 | +------+-------+ | 95 | 2/3 | +------+-------+ | 96 | 1/3 | +------+-------+ | 97 | 2/3 | +------+-------+ | 98 | 1/3 | +------+-------+ | 99 | 2/3 | +------+-------+
def OrbitDisplay(fcn,x0,skip=0,maxit=10): FullOrbit = [] OrbitDisplay = [] var('nextx, oldx') oldx = x0 for i in range(0,maxit): nextx = fcn(oldx) FullOrbit.append(nextx) oldx = nextx return FullOrbit[skip:maxit] fcn(x) = 3*x*(1-x) fcn2(x) = fcn(fcn(x)) print table(columns = [range(40,45),OrbitDisplay(fcn2(x),.1,40,45)],header_row=['iter','orbit'],frame=true)
+------+-------------------+ | iter | orbit | +======+===================+ | 40 | 0.641594498760650 | +------+-------------------+ | 41 | 0.641867522278635 | +------+-------------------+ | 42 | 0.642131835724847 | +------+-------------------+ | 43 | 0.642387893032981 | +------+-------------------+ | 44 | 0.642636115649511 | +------+-------------------+