Some mathematical helpers.