# L-29 MCS 260 Fri 2 Nov 2007 : floppoly # # We use FlopFloats to count the number # of operations to evaluate a polynomial # of degree d with random coefficients. from flopfloats import * from random import gauss print '#flops to evaluate a polynomial' d = input('Give degree : ') x = FlopFloat(gauss(0,1)) sum = FlopFloat() for i in range(0,d+1): r = FlopFloat(gauss(0,1)) for j in range(0,i): r = r*x sum = sum + r print 'evaluating a polynomial of degree '+ \ '%d \ntakes %d flops' % (d,sum.flops)