# L-25 MCS 507 Wed 19 Oct 2011 : floppoly.py

# We use FlopFloats to count the number of
# operations when evaluating a polynomial.

from flopfloats import *

p = '(x**4)*6 - (x**3)*3.23 - x**2' \
  + '+ x*0.3553 - 9.23'
print 'counting flops in', p
n = input('Give x : ')
x = FlopFloat(n)
print x
y = eval(p)
print 'y = ' + str(y) + \
   ' #flops is %d' % y.flops
