Hamiltons characteristic function