The calculations don't work as intended, since 1/2 == 0 in Python 2.x. Use explicit `float` or start the file with `from __future__ import division`