[Edu-sig] thought re graphing calculators ...

kirby urner kirby.urner at gmail.com
Mon Sep 28 23:10:13 CEST 2009

> Hi Brian,
> I think I have a counterexample.
> Run the script, that you can find here:
> http://svn.python.org/view/*checkout*/python/branches/release26-maint/Demo/turtle/tdemo_chaos.py?revision=73559&content-type=text%2Fplain
> (or below.) Runs with Python 2.6 or later.
> It certainly could be mimicked on
> a (programmable) graphics calculator.

This ran perfectly on Python 3.1rc1 (r31rc1:73069, May 31 2009,
08:57:10) on my WinXP box (one of a few).

Note:  if this level of chaos / noise bothers you (the functions are
algebraically the same, after all), then I recommend using the decimal
type instead of the floating type, converting to float just to make
your turtle happy:

# File: tdemo_chaos.py
# Author: Gregor Lingl
# amended to use Decimal by Kirby Urner 2009-09-28
# Date: 2009-06-24

# A demonstration of chaos

from turtle import *
from decimal import Decimal

k = Decimal('3.9')

N = 80

def f(x):
 x = Decimal(str(x))
 return k*x*(1-x)

def g(x):
 x = Decimal(str(x))
 return k*(x-x**2)

def h(x):
 x = Decimal(str(x))
 return k*x-k*x*x

def jumpto(x, y):
 penup(); goto(x,y)

def line(x1, y1, x2, y2):
 jumpto(x1, y1)
 goto(x2, y2)

def coosys():
 line(-1, 0, N+1, 0)
 line(0, -0.1, 0, 1.1)

def plot(fun, start, colour):
 x = start
 jumpto(0, x)
 for i in range(N):

def main():
 setworldcoordinates(-1.0,-0.1, N+1, 1.1)
 plot(f, 0.35, "blue")
 plot(g, 0.35, "green")
 plot(h, 0.35, "red")
 # Now zoom in:
 for s in range(100):
     setworldcoordinates(0.5*s,-0.1, N+1, 1.1)
 return "Done!"

if __name__ == "__main__":


More information about the Edu-sig mailing list