#!/usr/bin/env python #Author: Shriphani Palakodety #Mail: shriphani@shriphani.com #Blog: http://shriphani.com/blog #A plot of the Zeta function using Python + matplotlib #import the required modules: from pylab import * def zetaValue(n): val = 0 #We got to start somewhere for i in range(1, n+1): zeta_term = float(1)/float(i**2) val += zeta_term return val def makePlotRange(): num_list = [] range_list = [] for i in xrange(1,1000): num_list.append(i) range_list.append(zetaValue(i)) return num_list, range_list plot_range = makePlotRange() constant = [1.65] * len(plot_range[0]) #plot(t, zetaValue(t), 'r--', t, 1.69, 'bs') plot(plot_range[0], plot_range[1], 'bs', plot_range[0], constant, 'r--') savefig('zetaplot.png') show()