def wrap_to_centered_interval(x: float, center: float, half_width: float
    ) ->float:
    """
    Given an interval (［center-half_width, center+half_width),
    map x to this interval by assuming the interval repeats infinitely.
    """
    return (x - (center - half_width)) % (2.0 * half_width) + (center -
        half_width)
