differ.py

import string
from visual.graph import *

filename = raw_input("Enter data file name: ")
file = open(filename,'r')

fgraph = gdisplay(title="function")
fcurve = gcurve(gdisplay=fgraph)

dgraph = gdisplay(title="Derivative")
dcurve = gcurve(gdisplay=dgraph)

lines = file.readlines()

x0,y0 = map(float,string.split(lines[0]))



for line in lines[1:]:
    x1,y1 = map(float,string.split(line))
    
    derivative = (y1-y0)/(x1-x0)

    fcurve.plot(pos=(x0,y0))
    dcurve.plot(pos=(x0,derivative))

    x0 = x1
    y0 = y1

Generated by GNU enscript 1.6.3.