# note that Python does all computations in double precision from math import * def plot(a, b, n, f, filename): outf = open(filename, "w") dx = float(b-a)/(n) for i in range(n+1): x = a+dx*i outf.write("%g\t%g\n" % (x, f(x))) plot(-5e-8, 5e-8, 1000, lambda x: 1-cos(x), "1-cos.dat")