Here we plot the function over the interval (0,1):
As a remark, we can get rid of those vertical lines (which arise because Sage doesn't realize that the function is not continuous) using the exclude parameter:
plot(D,(x,0,1),aspect_ratio=1,exclude=[1/2,1])# exclude corrects the plotting for discontinuities
defforward_orbit(x,T,N):''' Return the list [x, T(x), ..., T^N(x)]. '''orbit=[x]# Start of the orbit.y=xforiinrange(N):y=T(y)# Redefine y to be T(y)orbit.append(y)# Add y at the end of the orbit.returnorbit
Recall that a fixed point of D is a value x so that D(x)=x. Zero is a fixed point:
A periodic point of D is a point x so that Dk(p)=p for some k≥1. The least period (or prime period) of p is the smallest such k. We say x has period k if Dk(x)=x.
The number 31 has least period two, since the following output shows that D(1/3)=2/3 and D2(1/3)=1/3.
[1/3, 2/3, 1/3]
A cobweb plot is a useful way to visualize an orbit of a map T:R→R. It involves several things:
The graph of the function f.
The diagonal (the graph of the identity map)
The orbit is visualized as the sequence of points (the cobweb path)
The following function draws a cobweb plot of the orbit of x, connecting (x,x) to (TN(x),TN(x)) by a cobweb path:
defcobweb(x,T,N,xmin,xmax):cobweb_path=[(x,x)]foriinrange(N):y=T(x)# Reassign y to be T(x).cobweb_path.append((x,y))cobweb_path.append((y,y))x=y# Reassign x to be identical to y.cobweb_plot=line2d(cobweb_path,color="red",aspect_ratio=1)function_graph=plot(T,(xmin,xmax),color="blue")# define the identity map:identity(t)=tid_graph=plot(identity,(xmin,xmax),color="green")returncobweb_plot+function_graph+id_graph
Here is the cobweb plot of 1/3:
The point 1/5 has period 4:
Here is another phenomenon. The point 1/6 is pre-periodic or eventually periodic. This means that there is a k>0 so that Dk(1/6) is periodic. For 1/6, this k is one since D(1/6)=1/3, and above we showed that 1/3 is period 2:
Lets compute the least period of 73/103:
x=D(73/103)k=1whilex!=73/103:x=D(x)k=k+1print("73/103 has least period "+str(k))
73/103 has least period 51
Exercise: Think about why if p/q is a fraction, then it must be either periodic or eventually periodic under D. Under what conditions is it periodic? When is it eventually periodic?