Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168738
Image: ubuntu2004

User Defined Variables

f(xt): updating function associated with DTDS
x0: initial condition
f(xt) = sin(pi*xt/2)+xt x0 = .5 #---------------------------- do not change --------------------------------- s = [] s.append(x0) stop = 0 i = 0 while stop == 0: s.append(f(s[i])) i = i+1 if (abs(s[i] - s[i-1]).n(16) < .05): stop = 1 if (i > 10): stop = 1 #Set up graph of function P = plot(f,0, max(s)+.1) # Set up graph of diagonal P = P + plot(xt,0, max(s)+.1, color='black', linestyle = '--') # Set up cobwebbing P = P + line([(s[0],0),(s[0],s[1])], rgbcolor=(1,0,0), linestyle = '--') P = P + point([(s[0],s[1])], rgbcolor=(1,0,0), pointsize=30) P = P + line([(s[0],s[1]),(s[1],s[1])], rgbcolor=(1,0,0), linestyle = '--') for i in range(1,len(s)-1): P = P + line([(s[i],s[i]),(s[i],s[i+1])], rgbcolor=(1,0,0), linestyle = '--') P = P + point([(s[i],s[i+1])], rgbcolor=(1,0,0), pointsize=30) P = P + line([(s[i],s[i+1]),(s[i+1],s[i+1])], rgbcolor=(1,0,0), linestyle = '--', axes_labels=['$x_t$','$x_{t+1}$']) # Graph it all P.show(aspect_ratio=1 )