Quadratic functions in geometry, topology, and M-theory