sequence.py

#---------------------------------------
# SEQUENCE.PY - successive approximation
#    program from Callahan pg. 72
#---------------------------------------

#Setup Graphics
from visual.graph import *
graph = gdisplay() #create a graphing window

for j in range(1,15):
    tinitial = 0
    tfinal = 75
    t = tinitial
    y = 100
    numberofsteps = 2**(j-1)
    deltat = (tfinal - tinitial) / float(numberofsteps)

    #create a new curve on the graph
    curve = gcurve()

    curve.plot(pos=(t,y))
    for k in xrange(numberofsteps):
        yprime = .1*y*(1-y/1000.0)
        deltay = yprime * deltat
        t = t + deltat
        y = y + deltay
        curve.plot(pos=(t,y)) # add a point to the graph

Generated by GNU enscript 1.6.3.