def clamp(x: float, x0: float, x1: float) ->float:
    """
    Clamp x to lie within the interval [x0, x1]

    :param x: the value to clamp
    :type x: float
    :param x0: left edge of the interval
    :type x0: float
    :param x1: right edge of the interval
    :type x1: float
    :return: x restricted to [x0, x1]
    :rtype: float
    """
    return max(x0, min(x, x1))
